Link to home
Start Free TrialLog in
Avatar of jamie_lynn
jamie_lynn

asked on

How can I recursive grep excluding the symlinks?

Hi,

How can I do a recursive grep excluding the symlinks?

Thanks
Jamie
ASKER CERTIFIED SOLUTION
Avatar of Joseph Gan
Joseph Gan
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jamie_lynn
jamie_lynn

ASKER

Hi ganjos,

Would this not go into the symlink directory or just hide the results?
I need grep not even to go into the symlink directory, as there are symlinks that point to itself.

Thanks
Jamie
No, symlink is not a directory, it is a file.
Basically, symlink links two files, but if the target is a directory, another file named "source file" is created in target and linked to the original "source file". So eventually links two files as well.

You can do a quick test in /usr/bin directory with the command. Hopefully this answered your question.
Ah i see.
Thanks!
That works
I thought you wanted to do a recursive grep and not a recursive ls.

For a recursive grep excluding symlinks, just do:

find . -type f | xargs grep string