2
I'm trying to find a specific line from the newest file I have in subfolders. Files have the same name. So structure is like:
- Folder
- SubFolder1
- filename.xml
- SubFolder2
- filename.xml
- SubFolder1
I'm using grep to have the line
grep -r "mySubString" folder/
I've try using find to sort files as proposed here. But I don't know how to combine both to get just the line from the newest file.
Thanks for your help.
it is not clear whether you want to run
grep
on the latest file, even if it finds nothing, or whether you want the output from the latest file wheregrep
finds a match. – AFH – 2014-10-07T09:49:15.913Thanks AFH for your comment. I want to run the grep in the newest file. – Mario Levrero – 2014-10-07T10:12:40.487
In that case @ap0 gives the neatest answer below, but it will need modification if you want to know which of the files the string came from. – AFH – 2014-10-07T10:20:46.113