grep
The grep is used to identify patterns in a file and show the lines that match the pattern. This also includes its switches:
- grep -v = shows the lines that does not match the pattern
- grep -i = searches through the file with case insensitive
Examples:
grep "is" file01.txt
grep -i "error" logfile.txt
wc
The wc or word count command displays the number of lines, words
, letters in the given file. It's switches consist of:
- wc -m = prints the character counts
- wc -l = prints the number of lines
Examples:
wc linuxfile.txt
wc -m linuxfile.txt
sort
The sort filter can be used to show the output in a sorted order in the terminal. It will not actually sort the order within the file. Sort has so many switches but few of them are:
- sort -f = is case insensitive when it comes to sorting
- sort -n = compare and sort according to numerical value
Example:
sort file01.txt
sort -f file01.txt
uniq
The uniq command displays only the unique contents within the file. It has quite a few switches namely:
- uniq -c = prints the count of occurrence of a word
- uniq -i = ignores the case sensitive
Example:
cat file01.txt | uniq
sort file01.txt | uniq -c
whoami
This command displays the current user of the system.
Example:
whoami
Top comments (0)