Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you exclude symlinks in a grep?

Tags:

grep

I want to grep -R a directory but exclude symlinks how dow I do it?

Maybe something like grep -R --no-symlinks or something?

Thank you.

like image 874
Drew LeSueur Avatar asked Feb 12 '14 20:02

Drew LeSueur


People also ask

How do you exclude something in grep?

Exclude Words and Patterns To display only the lines that do not match a search pattern, use the -v ( or --invert-match ) option. The -w option tells grep to return only those lines where the specified string is a whole word (enclosed by non-word characters). By default, grep is case-sensitive.

How do I bypass symlinks?

Overwriting Symlinks If you try to create a symbolic link that already exists , the ln command will print an error message. To overwrite the destination path of the symlink, use the -f ( --force ) option.

Does grep follow symlinks?

When searching with grep -r , it avoids following symbolic links by default. This is true for directories, but grep still inspects the contents of files that are symlinks.

Does rm remove symlinks?

The rm command is the dedicated tool for deleting files and directories from the system. Because the symlink itself is a file, we can use the rm command to remove it. The following rm command will remove the symlink. To remove multiple symlinks, use rm as you would to remove multiple files.


1 Answers

Gnu grep v2.11-8 and on if invoked with -r excludes symlinks not specified on the command line and includes them when invoked with -R.

like image 98
Aryeh Leib Taurog Avatar answered Oct 28 '22 05:10

Aryeh Leib Taurog