Reputation: 95
I write the following script, expecting to print files in a directory. But it is just throwing the string "ls" on to screen.
What is the problem?
#!/bin/bash
for FILE in 'ls'
do
echo $FILE
done
Upvotes: 0
Views: 461
Reputation:
Wrong kind of quotes - you want:
for FILE in `ls`
Those are the backticks, not the single-quotes. Better still:
for FILE in $( ls )
You might also want to look at this site.
Upvotes: 9