I have 2 lines of code
1) With the following code:
for i in `ls *.properties`; do cat $i; done
I get the error:
cat: file_name.properties: No such file or directory.
2) On the other hand:
for i in *.properties; do cat $i; done
Works fine!
I thought both were the same. Can someone help me understand the difference between the two? Using bash shell.
for i in `ls`
. It might also be helpful to doif [[ -f $i ]]; then cat "$i"; fi
to make sure you're only getting files and not directories. Note also that the variable should be quoted as I have done. – Dennis Williamson May 15 '12 at 21:04