Unix Commands Flashcards
Basic utilities are
grep, sed, awk, etc
grep stands for
global regular expression print
basic grep command
grep “searchtext” filename
grep -n “searchtext” filename
shows the matched text with line numbers
grep -vn “searchtext” filename
shows the results and the lines that don’t match the searchtext
grep - c “searchtext” filename
suppress printing of the matching lines but display only the number
grep -l “searchtext” *
shows the file name in which the searchtext is found
grep -i “SEARCHTEXT” filename
ignores the case and displays the results
grep -x “searchtext” filename
displays only the exact match
grep -A2 “searchtext” filename
displays the matched text plus additional two rows
% ls
lists the contents of your current working directory whose name doesn’t begin with a dot (.)
% ls -a
to list all files in your home directory including those that begin with a dot (.)
% mkdir
to make a sub directory
% cd
to change to a directory
% cd .
in unix . means current directory. this command is to stay in the same directory