Category Archives: Guest Blog

USING THE grep UTILITY

[This was originally published by Mike Brooks as a wiki entry and I have moved it here - Wolf]
USING THE grep UTILITY

Since the acquisition of certain data is many times critical, the grep utility is a valuable tool for the Linux user. It allows you to search through one or more files to see whether any contain a specified string of characters. This utility does not change the file it searches but simply displays each line that contains the string.

Originally, the name grep was a play on an ed— an original UNIX editor, available on Fedora/RHEL— command: g/re/p. In this command g stands for global, re is a regular expression delimited by slashes, and p means print. Read more

Specify A Command From History

One can specify an event from their history on the input line to repeat it.

The easiest way to specify an event from history is to use the up and down arrow keys. The up arrow key (<>) steps backwards through command events and the down arrow key (<>) steps forward through events. When an event is on the input line it can be edited it as if it were on the command line or type <Enter> to run it; it then become the most recent event in shell history.

Example…
Specify the second-to-last command…
$ <> <>

To specify an event by its number enter an exclamation point (!, a.k.a a “bang”) followed by the event number.

Example…
Run history event number 1…
$ !1 <Enter>

Observe event number “!” is the last event thus typing !! is another way to rerun the last command.

== Alonzo Fretwell holds a BS in Computer Science which he earned in 1997 from the Howard R. Hughes College of Engineering located on the campus of the University of Nevada, Las Vegas. Mr. Fretwell also blogs about Linux and iPhones at http://alonzofretwell.com