Skip to content

Instantly share code, notes, and snippets.

@CliveIMPISA
Created March 6, 2015 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CliveIMPISA/91f21be89ccd293ef2bc to your computer and use it in GitHub Desktop.
Save CliveIMPISA/91f21be89ccd293ef2bc to your computer and use it in GitHub Desktop.
Displaying contents of files
% less filename.txt - writes the contents of a file onto the screen a page at a time
- Press the [space-bar] if you want to see another page
% head filename.txt - writes the first ten lines of a file to the screen.
% head -5 filename.txt - write the first five lines. The number 5 can be changed to display the desired number of lines.
% less filename.txt - displays the last 15 lines of a file
% grep - Searches file for pattern or word
usage ( % grep word_to_search filename.txt)
% grep -i word_to_search filename.txt - the -i ignores the upper/lower case distinctions
% grep -v word_to_search filename.txt - display those lines that do NOT match
% grep -n word_to_search filename.txt - precede each matching line with the line number
% grep -c word_to_search filename.txt - print only the total count of matched lines
% wc
% wc -w filename.txt - count all the words
% wc -c filename.txt - count all the characters
% wc -l filename.txt - count all the line
% wc filename.txt - displays total lines, words and characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment