wildcard

Hi, I have this code to search all "cif" files using wildcard

for file in *.cif
do
grep "Uiso" $file | awk '{ print $3, $4, $5 }' > tet
done

I get this error
"grep: *.cif: No such file or directory"

Please where am I going wrong!!!

Thank you in advance

Try....

for file in *.cif
do
echo $file | grep "Uiso" $file | awk '{ print $3, $4, $5 }' > tet
done

I have tried that and I get the same error as before "grep: *.cif: No such file or directory"

It appears to me that you shell is not able to evaluate the *.cif. Try this

for file in `ls *.cif`
do
grep "Uiso" $file | awk '{ print $3, $4, $5 }' >> tet
done

cheers,
Devaraj Takhellambam

Here you overwrite tet file for each match file in loop ! , that's what you want ?

Yep , no match , grep can't find the file.

Solution(awk and shell redirect):

awk '/Uiso/{ print $3, $4, $5 }' *.cif 2>/dev/null >> tet

No that i would want to say is this....

Try....

for file in *.cif
do
echo $file | grep "Uiso" | awk '{ print $3, $4, $5 }' > tet
done

Which shell are you using?
As danmero states you will overwrite the output file for every grep.
Here is an alternative which uses find to expand the filenames.

#!/bin/ksh
>tet        # Initialise output file
(
find . -name '*.cif' -print | while read file
do
           grep "Uiso" "${file}" | awk '{ print $3, $4, $5 }'
done
) >> tet