Solved

How can I recursive grep excluding the symlinks?

Posted on 2010-09-21
7
3,702 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

707 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