I have a logfile with some filenames inbetween other events, which I need to find in subfolders. Same necessity for filenames inside xml files which has to be found inside some folder and subfolders. Looks to me I should use grep on the logfile and extract exact filenames, feed those to find. I can easily get a list of filenames one per line, but getting it to work with find is not exactly working. And internet is full with answers for other way around - find results feeding into grep.
grep -oP '(?<=Some problem with file named ).*pdf(?=\.)' /home/myname/log/myspecificlogfile.log
I tried piping results of this command to xargs and find, but it doesnt give any results both on files not actually there and ones there. Echo is just to simplify, find parameter -ls is not yet added (but I will need it):
echo 12345.pdf | xargs -0 -I{} find /home/myname/workfolders/ -name '{}' #Nonexisting pdf
echo 67890.pdf | xargs -0 -I{} find /home/myname/workfolders/ -name '{}' #Existing pdf, no results
How do I get grep results piped to find to find my files in a folder and eventually subfolders?
?
afterpdf
intended? That would be like(pdf|pd)
.b?
is an optionalb
(0 or 1b
, same asb{0,1}
).bbb?
is twob
s followed by an optionalb
.pdf
ispd
followed by an optionalf
. Which doesn't sound like that's what you'd want.