I was just trying the below code and it is not working.. please suggest to correct this code..
echo abc.txt | while read name; do find . -name $name; done
output success : ./rak/abc.txt
echo 'abc.txt pqr.txt' | while read name; do find . -name $name; done
output error : find: 0652-009 There is a missing conjunction
echo "abc.txt pqr.txt" | while read name; do find . -name $name; done
output error : find: 0652-009 There is a missing conjunction
same error with
echo "abc.txt" "pqr.txt" | while read name; do find . -name $name; done
echo 'abc.txt' 'pqr.txt' | while read name; do find . -name $name; done
Please suggest how to resolve this problem…
The problem is that the multiple entries are sent into the pipe as one line, the read picks up both strings into
nameand then processes the$namecontaining the two strings.You should use something like:
i.e. separate the items with a newline.
You should have tried debugging this by using
echo "'$name'"instead of thefindand it would have hinted what was happening.Additionally, I would use quoting around the use of
$namein the find, as if the filename is expected to have a space in it’s name then you will get the same error message as you have experienced originally.