How can I recursive grep excluding the symlinks?

Hi,

How can I do a recursive grep excluding the symlinks?

Thanks
Jamie
jamie_lynnAsked:
Who is Participating?
 
Joseph GanConnect With a Mentor System AdminCommented:
ls -lR | grep -v "^l"
0
 
jamie_lynnAuthor Commented:
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
0
 
Joseph GanSystem AdminCommented:
No, symlink is not a directory, it is a file.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
Joseph GanSystem AdminCommented:
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.
0
 
jamie_lynnAuthor Commented:
Ah i see.
Thanks!
0
 
jamie_lynnAuthor Commented:
That works
0
 
TintinCommented:
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

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.