I have two files.
file1.txt: Afghans Africans Alaskans ...
where file2.txt contains the output from wget on the web page, so it is a big messy mess, but it contains a lot of words from the first list.
Bashcript:
cat file1.txt | while read LINE; do grep $LINE file2.txt; done
This did not work as expected. I wondered why, so I repeated the $ LINE variable inside the loop and added sleep 1, so I could see what was happening:
cat file1.txt | while read LINE; do echo $LINE; sleep 1; grep $LINE file2.txt; done
The result looks in the terminal like this:
afghans
Africans
Alaskans
Albanians
the Americans
grep: Chinese: No such file or directory
: No such file or directory
Arabs
Arabs
Arab / East Indians
: No such file or directory
Argentinans
Armenians
Asian
Asian Indians
: No such file or directory
file2.txt: Asian Naruto
...
So you can see that he finally found the word "Asian". But why does he say:
No such file or directory
?
Is there something strange or am I missing something?
Kevin source share