I have a list of directories in a text file, wherein I want to find and change files that share a particular naming convention.
example file:
dir1
dir2
dir3
example folder structure with files
dir1/
thing.txt
thing.blah
dir2/
rar.txt
thing.blah
dir3/
apple.txt
another.text.file.txt
thing.blah
First, I find the name of the .txt, but then I want to perform a change on it. For example, i want to perform a sed command on thing.txt, rar.txt and apple.txt, but not another.text.file.txt.
My question is, once I have all the file names, how do I perform a command on the files with those names? How can I then take those lines of text such as:
cat dirFile.txt | xargs ls | grep <expression>.txt
thing.txt
rar.txt
apple.txt
!cat | some command
and run an action on the actual files under the directories?
What I'm getting is the above result,
But what I need is
dir1/thing.txt
dir2/rar.txt
dir3/apple.txt