Solved

How can I recursive grep excluding the symlinks?

Posted on 2010-09-21
7
3,213 Views
Last Modified: 2013-12-27
Hi,

How can I do a recursive grep excluding the symlinks?

Thanks
Jamie
0
Comment
Question by:jamie_lynn
  • 3
  • 3
7 Comments
 
LVL 16

Accepted Solution

by:
Joseph Gan earned 500 total points
ID: 33729495
ls -lR | grep -v "^l"
0
 

Author Comment

by:jamie_lynn
ID: 33729531
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
 
LVL 16

Expert Comment

by:Joseph Gan
ID: 33729651
No, symlink is not a directory, it is a file.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 16

Expert Comment

by:Joseph Gan
ID: 33729973
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
 

Author Comment

by:jamie_lynn
ID: 33730087
Ah i see.
Thanks!
0
 

Author Closing Comment

by:jamie_lynn
ID: 33730093
That works
0
 
LVL 48

Expert Comment

by:Tintin
ID: 33732467
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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now