Grep – Exclude multiple directories and files while using grep search

Thursday, 14. June 2012

Here is a good example of how to list files matching a certain pattern while exclude grep from performing search on multiple folders and files

Files Matching search term excluding multiple directories and files with grep

 
grep 'open source' -R . -il --exclude-dir={var,js,downloader,media} --exclude=*.{png,jpg,gif} --color

Using grep to search for a text within files recursively

Thursday, 14. June 2012

To search for text in files from the current folder recursively. you can :

grep text_to_search -R . -n --include=*.php --color

The parameters are as follows:

text_to_search
the actual text to search for

-R
Recurse to subdirectories

.
start from the current directory

?include=*.php
specifies a regular expression that searchable files must match (in my case, search only files with the ‘php’ extension)

?color
makes the output pretty

-n
shows the lines numbers of the lines that matched your search text

Launch Gnome Terminal and execute a command in debian linux

Sunday, 10. June 2012

A snippet you would need to launch a terminal command (gnome terminal) and execute a command line

gnome-terminal -e "ssh [email protected]"

enjoy!