I have a find command nested within a loop and I want to write the output to a file and be able to see it live as well. But every approach I have tried so far has failed to fulfill this.
My while command is this:
while read -r LINE; do find "$LINE" -name "*Bop*" ; done < /drives/d/dirs_to_search.txt
When I run the command above, I can see the list of matching sub-directories printed into my terminal window. I want to keep seeing this list of matches, but at the same time write them to a file.
And the approaches I have tried so far to write the output of find to a file named matched_subdirs:
while read -r LINE; do find "$LINE" -name "*Bop*" | tee /drives/d/matched_subdirs.txt ; done < /drives/d/dirs_to_search.txt
while read -r LINE; do find "$LINE" -name "*Bop*" ; done < /drives/d/dirs_to_search.txt | tee /drives/d/matched_subdirs.txt
while read -r LINE; do find "$LINE" -name "*Bop*" -print; done < /drives/d/dirs_to_search.txt | tee /drives/d/matched_subdirs.txt
while read -r LINE; do find "$LINE" -name "*Bop*" > /drives/d/matched_subdirs.txt ; done < /drives/d/dirs_to_search.txt
while read -r LINE; do find "$LINE" -name "*Bop*"; done < /drives/d/dirs_to_search.txt > /drives/d/matched_subdirs.txt
findto do what you need to de with them.rsyncloop--a loop similar to the one in my post above--later on.teeshould work (and does, on my Arch).