less command n less [options] file-list display files in ‘file-list‘ one screen at a time Options: -N display line number -p pattern search for the first occurrence of ‘pattern’ in the file $ less -Np 'author' my 24 --author 25 with -l, print the author of each file 26 27 -b, --escape $ less -N my 1 GNU bash, version 3. 2. 25(1)-release (i 386 -redhat-linux-gnu) 2 These shell commands are defined internally. Type `help' to see this list. 3 Type `help name' to find out more about the function `name'. Exit: ctrl+z or q It starts displaying file without reading all the file, which makes more efficient than the more commands Jozef Goetz, 2014 4

Viewing Contents of Text Files Viewing the Head or Tail of a File n n n head [option][file-list] -n – display 1 st n lines tail [option][file-list] -n – display last n lines $ head my line 1 line 2 line 3 line 4 line 5 line 6 $ head -2 my line 1 line 2 ~$ tail my line 1 line 2 line 3 line 4 line 5 line 6 $ tail -3 my line 4 line 5 line 6 Jozef Goetz, 2014 see cmd more –n S more -5 my line 1 line 2 line 3 line 4 line 5 8

Removing Repeated Lines 18 uniq [options][+N][input-file][output-file] - remove repetitious lines from the sorted ‘inputfile’ and send unique lines to ‘output-file’ Options: -c precede each output line by # of occurs -d display repeated lines -u display unrepeated lines $ cat sample This is a test file for the uniq command. It contains some repeated and some nonrepeated lines. Some of the repeated lines are consecutive, like this. And, some are not consecutive, like the following. Some of the repeated lines are consecutive, like this. The above line, therefore, will not be considered a repeated line by the uniq command, but this will be considered repeated! $ uniq sample This is a test file for the uniq command. It contains some repeated and some nonrepeated lines. Some of the repeated lines are consecutive, like this. And, some are not consecutive, like the following. Some of the repeated lines are consecutive, like this. The above line, therefore, will not be considered a repeated line by the uniq command, but this will be considered repeated! $ Jozef Goetz, 2014

Removing Repeated Lines 19 uniq [options][+N][input-file][output-file] $ 1 1 3 1 1 1 2 Options: -c precede each output line by # of occurs -d display repeated lines -u display unrepeated lines uniq -c sample This is a test file for the uniq command. It contains some repeated and some nonrepeated lines. Some of the repeated lines are consecutive, like this. And, some are not consecutive, like the following. Some of the repeated lines are consecutive, like this. The above line, therefore, will not be considered a repeated line by the uniq command, but this will be considered repeated! $ uniq -d sample Some of the repeated lines are consecutive, like this. line by the uniq command, but this will be considered repeated! $ uniq -d sample out $ cat out Some of the repeated lines are consecutive, like this. line by the uniq command, but this will be considered repeated! $ Jozef Goetz, 2014