[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to convert 100 bmp files to jpeg?



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tim Connors wrote:
> Nope.
> 
> #mkdir tmp
> #cd tmp
> #for i in `seq 1 10000` ; do touch "blah $i" ; done
> #for f in `ls *`; do ls -lA "$f"; done
> ls: blah: No such file or directory
> ls: 1: No such file or directory
> ls: blah: No such file or directory
> ls: 10: No such file or directory
> ls: blah: No such file or directory
> ls: 100: No such file or directory
> ls: blah: No such file or directory
> ls: 1000: No such file or directory
> ls: blah: No such file or directory
> ....
> 
> Because each space output by the backticks causes the for loop to plop
> the next bit into a new loop.


We can use IFS is ls is really needed (for a command line option or
whatever) :

___________________________________________________________________________
theo@copernic$ touch "1 2 3" 12 13
theo@copernic$ for i in *; do ls "$i"; done
12
1 2 3
13
theo@copernic$ for i in  $(ls *); do ls "$i";done
12
ls: 1: No such file or directory
ls: 2: No such file or directory
ls: 3: No such file or directory
13
theo@copernic$ IFS=$'\n'; for i in  $(ls *); do ls "$i";done; unset IFS
12
1 2 3
13
___________________________________________________________________________


I'm not saying it's better to use ls though.



Cheers,
theo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDyw4YSH6NzHMSyhIRAv/IAKCG1lp5IeNeUoPNtsFSXqL804HuWwCeP82l
V03I8zU5PD7f+DplzBlXIaY=
=jLiO
-----END PGP SIGNATURE-----



Reply to: