what is wrong with this?
for i in 'ls | grep '^[A-Z]......$' do echo $i done
if i just use the command ls | grep '^[A-Z]......$ i get the files i want
What am i missing?
M
what is wrong with this?
for i in 'ls | grep '^[A-Z]......$' do echo $i done
if i just use the command ls | grep '^[A-Z]......$ i get the files i want
What am i missing?
M
you mean
for i in `ls | grep '^[A-Z]......$'`;do echo $i;done
? actully this is difference between ` and ' , limited within your shell, and not a regex or OS problem.
Shouldn't those be backticks?
for i in `ls | grep blahblahblah`; do echo $i; done
When you use the backtick: "`" instead of the single quote "'" the output of the program between the backticks will be used as input for the shell, i.e.
for i in `ls | grep '^[A-Z]......$'`;do echo $i;done
the thing that is "wrong" , is that there is no need to use external ls
command to list your files and grep your pattern. Just use the shell.
for file in [A-Z]??????
do
echo $file
done