Grep
Let's say you want to search for the text 'amigo' within a directory. You can use:
grep -r 'amigo' /home/guest/mydir.
If you start getting errors like 'No such file or directory' and you want to ignore them, the option -s can be used. So it'll become
grep -r -s 'amigo' /home/guest/mydir.
Here -r is for recursive search within a directory and -s for skipping error messages.
And if we want to exclude searching certain type of files, like SVN and xml files, we can use:
grep -r -s -n --exclude=*.{svn*,xml} 'PATTERN' .
Another useful feature is if we want to exclude certain directories from the search altogether. For this we can use --exclude-dir=Tests .
grep -r 'amigo' /home/guest/mydir.
If you start getting errors like 'No such file or directory' and you want to ignore them, the option -s can be used. So it'll become
grep -r -s 'amigo' /home/guest/mydir.
Here -r is for recursive search within a directory and -s for skipping error messages.
And if we want to exclude searching certain type of files, like SVN and xml files, we can use:
grep -r -s -n --exclude=*.{svn*,xml} 'PATTERN' .
Another useful feature is if we want to exclude certain directories from the search altogether. For this we can use --exclude-dir=Tests .
This comment has been removed by the author.
ReplyDelete