Hello guys,
I have the following structure :
root : h235 - /tmp/test> ls -l
drwxr-xr-x 2 root root 1024 dc 14 12:28 a dir
drwxr-xr-x 2 root root 1024 dc 14 15:04 another one
drwxr-xr-x 2 root root 1024 dc 14 12:28 the last one
That is, directories with spaces in their names. And I have trouble using
the following for loop :
for i in `ls`; do echo $i; done
Since the default separator is space, i get 6 arguments.
I've tried playing with IFS the following way :
root : h235 - /tmp/test> liste=`ls -F`
root : h235 - /tmp/test> echo $liste
a dir/ another one/ the last one/
root : h235 - /tmp/test> IFS=/
root : h235 - /tmp/test> for i in $liste; do echo $i; done
a dir
another one
the last one
root : h235 - /tmp/test>
Why do I get those empty lines ? And has anyone a solution ?
Thanks
Christian