Common Shell Commands


Command

Action

grep pattern filename

Searches the file filename for the specified pattern or regular expression. (See Chapter 8; also refer to Chapter 11, "Introduction to Perl Programming," for more information on regular expressions.)

less filename

Views the contents of filename one screen at a time. The more command is a synonym for less. (See Chapter 8.)

cat filename

Displays (catenates) the contents of filename. cat is normally used with redirection or pipes to send a file's contents through another command. (See Chapter 8.)

wc filename

Displays the number of words, lines, and characters in filename. (See Chapter 8.)

diff file1 file2

Compares the contents of file1 with the contents of file2 and then displays the differences between these files. You can use -r to recursively compare the contents of whole directories. (See Chapter 8.)

fmt filename

Formats filename by wrapping its lines so that it's suitable for emailing. Output is sent to STDOUT by default. (See Chapter 8.)

cut options filename

Displays only a particular column or field from tabular data in filename. Output is sent to STDOUT by default. (See Chapter 8.) A corresponding command, used for combining multiple files into a text table, is paste.

head filename

Displays the first 10 lines of filename. Use a different number as an option (for example, -50) to see that number of lines. (See Chapter 8.)

tail filename

Displays the last 10 lines of filename. Use a different number as an option (for example, -50) to see that number of lines. (See Chapter 8.)

sort filename

Sorts the contents of filename into alphabetical order, or (if the -n option is used) numerical order. Output is sent to STDOUT by default. (See Chapter 8.)

cal

Displays a calendar for the current month. The -y option shows all the months of the year, and -y year shows the specified year. (See man cal for more information.)

date

Displays the current date and time. The root user can also use this command to change the date and time. Many formatting options are available. (See man date for more information.)

man command

Displays the manual page for command. (See Chapter 8.)

vi

Invokes the vi text editor. If a filename is specified, that file will be opened. (See Chapter 6, "Working with Applications.")

ee

Invokes the FreeBSD Easy Editor. If a filename is specified, that file will be opened. (See Chapter 6.)





FreeBSD 6 Unleashed
FreeBSD 6 Unleashed
ISBN: 0672328755
EAN: 2147483647
Year: 2006
Pages: 355
Authors: Brian Tiemann

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net