Portál AbcLinuxu, 29. prosince 2025 23:41
basename /home/OS/predtest/vstupy-2/test3/tento/tamten/plny/sub3or
/home/OS/predtest/vstupy-2/test3/tento/tamten/plny/sub3or
/home/OS/predtest/vstupy-2/test3/123_1/.siestY/test
/home/OS/predtest/vstupy-2/test3/tamten/iny
a potrebujem to odfiltrofat iba aby mi vypisalo tie posledne 3 elementy
user@stroj:~$ test="/home/OS/predtest/vstupy-2/test3/tento/tamten/plny/sub3or"
user@stroj:~$ echo ${test##*/}
user@stroj:~$ sub3or
A pro ořezání části cesty
user@stroj:~$ prefix="/home/OS/predtest"
user@stroj:~$ test="/home/OS/predtest/vstupy-2/test3/tento/tamten/plny/sub3or"
user@stroj:~$ echo ${test#$prefix}
user@stroj:~$ /vstupy-2/test3/tento/tamten/plny/sub3or
Atp... atp..
basename cesta
ls -ls -t `find /home/OS/predtest/vstupy-2/test3 -type f` | head -3 | awk '{print $10}' dostanem toto /home/OS/predtest/vstupy-2/test3/tento/tamten/plny/sub3or
/home/OS/predtest/vstupy-2/test3/123_1/.siestY/test
/home/OS/predtest/vstupy-2/test3/tamten/iny
a z toho potrebujem toto sub3or
test
iny
gawk -F / '{ print $NF; }'
`find ...` mám vždycky kopřivku... brrrrrrrrr
while read cesta; do basename $cesta; done.
`find` ne a ne a ještě jednou ne! Vždy, když vás to vede na řešení s `find` tak je to signál, že děláte něco špatně.find /home/OS/predtest/vstupy-2/test3 -type f -printf "%T@\t%f\n" | sort -nr | head -n 3 | cut -f 2
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.