shell - One command to find a list of file names within files in another folder -


i'm quite new unix commands , might intuitive of you, please forgive ignorance.

what want find .txt files in folder has other sub-folders files inside. using found list, should file name , extension (no full path), need search .xml files within folder (also have sub-folders , files , parent of first searched folder) occurrences of file names found in first search.

hope clear enough!

i tried , didn't work (i know, it's absolutely beginner's try):

find . -name "*.txt" -printf "%f\n" -exec find .. -name "*.xml" | xargs grep {} \; 

maybe somethiing (untested):

find . -name "*.txt" -printf "%f\n" > /tmp/a find . -name "*.xml" -exec grep -hff /tmp/a {} \;  

maybe add -w word-delimited searching.

another try @ process substitution:

find . -name "*.xml" -exec grep -hff <(find . -name "*.txt" -printf "%f\n") {} \; 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -