Hi, > Gesendet: Donnerstag, 06. Januar 2022 um 09:08 Uhr > Von: "Sascha Hauer" <sha@xxxxxxxxxxxxxx> > It works for example with: > > for i in /mnt/sd.1/extlinux/Image*; do basename $i b; echo $b; done this works with full path, but not if using a var for dir var barebox@BPI R2PRO:/ i=0;for f in /mnt/sd.1/extlinux/Image*; do basename $f b; echo "$i:$b";let i++; done 0:Image_5.16 1:Image_5.16-next.gz 2:Image_5.16.gz 3:Image_5.16.gz.bak 4:Image_5.16_q64 5:Image_bpi barebox@BPI R2PRO:/ imgdir=/mnt/sd.1/extlinux/ barebox@BPI R2PRO:/ i=0;for f in $imgdir/Image*; do basename $f b; echo "$i:$b";let i++; done basename - strip directory and suffix from filenames Usage: basename PATH VAR Remove directory part from the PATH and store result into variable VAR. 0:Image_bpi barebox@BPI R2PRO:/ any idea how to get it working with variable path? i can do a cd before and drop the basename cd $imgdir for f in Image*; do echo $f;done Image_5.16 Image_5.16-next.gz Image_5.16.gz Image_5.16.gz.bak Image_5.16_q64 Image_bpi but then i need to restore the path again (something like prevdir=$(pwd);cd $prevdir) if script fails regards Frank _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox