Solved

How can I recursive grep excluding the symlinks?

Posted on 2010-09-21
7
3,490 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
LastLogonTimeStamp Attribute 7 49
Linux : can't create transaction lock error 1 74
NTP Server in VMware 5 279
add some character at the end of line in vi 7 91
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…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

791 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