0

I have a folder with symlinks which are pointing to other folders, how can i recursively look into those folders? I would like to do a grep on those results to search for matches.

doing tree will only list the symlink as files.

1
  • grep -r 'somestring' *. Commented Mar 3, 2016 at 1:30

1 Answer 1

2

You can use find with the -L option, e.g.,

find -L . -type f -exec grep foo {} \; 

That makes find follow symbolic links. Quoting POSIX:

-L
Cause the file information and file type evaluated for each symbolic link encountered as a path operand on the command line or encountered during the traversal of a file hierarchy to be those of the file referenced by the link, and not the link itself. If the referenced file does not exist, the file information and type shall be for the link itself.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.