0

I have this single-line script:

while read line; 
    do grepresult=`grep -l -r "$line" | head -1`; 
    if[-n "$grepresult"] then 
        echo "$grepresult" 
     else
        echo "$line" fi;
 done < /tmp/list.txt > out.txt

This reads from a file a series of lines and tries to find them in a directory tree using with the grep. If it finds the text in this line, it writes the file, otherwise it should write the not found text. The script works fine, however I am getting trouble and I get for each line an error: No such file or directory.

Any idea why this error happens?

Peter G.
  • 14,786
  • 7
  • 57
  • 75
daniel sp
  • 937
  • 1
  • 11
  • 29

0 Answers0