Slippery Rock University Dr. Deborah Whitfield Go Browns!



Chapter 9: Filters


Boiled down:

filters more wc od
tail cut paste sort
head uniq tr diff

A few select unix commands:
Command Description
wc counts the lines, words and characters
wc -l filename counts the lines
wc -w filename counts the words
wc -c filename counts the characters
see the example
 
head outputs first ten lines
head -5 filename outputs first 5 lines
tail -6 filename outputs last 6 lines
see the example
head -12 filename| tail -6 outputs lines 7 - 12
see the example
 
cut -f2 filename cut column 2 out of file. Default delimiter is TAB
cut -d: -f2 filename cut column 2 out of file using : as delimiter
paste file1e file2 pastes files together via columns
see the example

A few select unix commands:
Command Description
echo displays text or values of variables
= Sets a variable to a value
try=hello
echo $try
Don't use spaces
to access value, use $
date displays current date and time
compress somefile reduces the size of file
Creates somefile.Z
uncompress somefile.Z restores somefile
see the example
 
sort filename alphabetically sorts
uniq filename removes duplicate lines
see the Notes
 
file filename type of the file
diff file1 file2 displays the differences in the file
< indicates line is from file1
> indicates line is from file2
which command displays directory of command that will be used (there may be different versions of the same command)
whereis command displays all places where (the directory) the command is found
apropos command same as man -k
see the example

All work herein is subject to copyright. Original content to Dr. Deborah Whitfield, text content (Your UNIX/Linux) to Prentice Hall publishing.