Here I collect useful text-processing commands. I don’t go into details. It’s just a convenient list to look up commands.


cat file.txt | sort

Remove duplicate lines:

cat file.txt | sort | uniq

Count number of line occurrence:

cat file.txt | sort | uniq -c | sort -nr

First/Last Lines

head -n $numberOfLines file.txt
cat file.txt | head -n $numberOfLines

tail -n $numberOfLines file.txt
cat file.txt | tail -n $numberOfLines

Find Files

# all files:
find . -type f

Way more commands:

To be continued…