Aw: Re: Re: barebox extending boot-scripts
Frank Wunderlich
frank-w at public-files.de
Sat Jan 29 02:40:08 PST 2022
Hi,
> Gesendet: Donnerstag, 06. Januar 2022 um 09:08 Uhr
> Von: "Sascha Hauer" <sha at pengutronix.de>
> 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 at 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 at BPI R2PRO:/ imgdir=/mnt/sd.1/extlinux/
barebox at 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 at 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
More information about the barebox
mailing list