ux4me
1
How to combine 3 find statements into 1-liner?
find statements:
cd ${dir1} ; find . ! -name . -prune -type f | xargs file | grep -i ascii | cut -f1 -d: | xargs grep -l "${searchtxt}"
cd ${dir2} ; find . ! -name . -prune -type f | xargs file | grep -i ascii | cut -f1 -d: | xargs grep -l "${searchtxt}"
cd ${dir3} ; find . ! -name . -prune -type f | xargs file | grep -i ascii | cut -f1 -d: | xargs grep -l "${searchtxt}"
pls advise and thanks in advance.
frans
2
find "$dir1" "$dir2" "$dir3" ! -name . -prune -type f | xargs file | grep -i ascii | cut -f1 -d: | xargs grep -l "${searchtxt}"
Should work.
No need to quote if you're sur there are no blanks in dir names.
Scott
4
Do you have any idea how unhelpful that kind of response is?
What doesn't work?
The command, such as it is, works fine for me.
ux4me
5
the proposed find statement below doesn't work as expected:
find "$dir1" "$dir2" "$dir3" ! -name . -prune -type f | xargs file | grep -i ascii | cut -f1 -d: | xargs grep -l "${searchtxt}"
no output from the above statement. this is because when dirs are specificied in the find, the statement couldn't find name "." which is not pruned.