1

I have something like a tree structure of directories, with some of them having inside a file named "Filename". Inside each of these files, there is some information that I would like to access after changing its "look". Here's what I have:

find . - name "Filename" | xargs perl -pe ...(one liner to change "look" of file, and put info i want to grep in one line) | grep "WhatIWantToShow" | egrep "exclude|some|stuff"

This works fine and it outputs the info I pretended. But I also need the directory name for each of the files found, and in which the grep was applied.

Thats now a big headache for me. Im stuck. Would appreciate if you guys can show me some light. Thanks.

  • Replace | xargs <stuff> by -exec <stuff> {} \; -printf '%h\n' maybe? May require GNU find. – steeldriver May 27 '17 at 19:55
  • using SunOS. is it possible? – Jorge May 27 '17 at 19:57
0

Instead of giving . in the find command try giving the complete folder name and check.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.