Tips tagged grep


Tip #215   Calendar with today colored [handle single digit dates]

If your version of grep supports coloring matches, you can use the following to give a calendar with the current date colored:

Read more »


Tip #192   Print a random shell-fu tip

Print a random shell-fu tip:
Read more »


Tip #189   Remove every file but one

It's easy to remove (or copy, move etc.) all files that match a given criteria, but harder to move all but ones excluded by a criteria.

To do this we can combine grep's -v option with Unix command substitution:

Read more »


Tip #22   Grepping for processes

Grepping for a process will return the grep command, this can be avoided by adding '| grep -v grep' to a command or easier in some cases altering the regular expression by adding brackets around a character.

Read more »


Tip #21  

Place a filename at the beginning of the line to make it easier to edit the search at the end of the command.

Read more »


Tip #48   Check low space

Mail somebody about space running low in some path (ksh, bash):

Read more »


Tip #64   Find occurrences of a string in a large code base without firing

example, look for all the TODO and HACK strings I left in large java project and show a bit of context before and after using the -C switch of grep.

Read more »


Tip #87  

Perform a recursive grep of the Solaris /etc directory, bypassing those nasty sockets Sun keeps in there:
Read more »


Tip #88   a better cut

use `grep -o` to select only the pattern matched rather than the whole line:

Read more »