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. Commented May 27, 2017 at 19:55
  • using SunOS. is it possible?
    – Jorge
    Commented May 27, 2017 at 19:57

1 Answer 1


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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .