to revert the search use -v:

grep -v 'pattern' file

extract config lines omitting remarks (#) and empty lines:

grep -v '^#' file.conf | grep -v '^$'

print also the filename where pattern matches:

grep -H 'pattern' *

watch disk usage while you're copying data to your usb drive:

watch -n 3 'df -hlm | egrep "Datei|usb"'


Every 3,0s: df -hlm | egrep "Datei|usb"                  Tue May  5 12:00:45 2009

Dateisystem          1M-Blcke   Benutzt Verfgbar Ben% Eingehngt auf
/dev/sda1               715275    394998    320278  56% /media/usbdisk

show all configured virtual hosts in the apache configuration:

grep ServerName virtual.conf | sed s"/ServerName "//g | sort

for i in vhosts*.conf; do grep ServerName $i | sed s"/ServerName "//g | sort; done
linux/grep.txt · Last modified: 2012-08 by tb
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready