Bash basics 2

head and tail select rows,
cut selects columns, and
grep “phrase” selects lines that contain “phrase“.
Note: grep -v: invert the match, i.e., only show lines that don’t match

** Writing to an output file
command > output_file

** To combine commands, use the pipe (|) — The pipe symbol tells the shell to use the output of the command on the left as the input to the command on the right.
head -n5 myfile.csv | tail -n3
cut -d, -f2 filename.csv | grep -v col_name — this passes the 2nd column of the file to grep which inverts (shows only the lines that do not match) data.  so the head row is removed

** Counting to the number of characters, words of lines
wc (word count)
wc -c (count characters)
wc -w (count words)
wc -l (count lines)

Other wild cards used for matching
? matches a single character, so 201?.txt will match 2017.txt or 2018.txt, but not 2017-01.txt.
[…] matches any one of the characters inside the square brackets, so 201[78].txt matches 2017.txt or 2018.txt, but not 2016.txt.
{…} matches any of the comma-separated patterns inside the curly brackets, so {*.txt, *.csv} matches any file whose name ends with .txt or .csv, but not files whose names end with .pdf.

Puts data in (By default ascending) order.
sort -n (sort numerically)
sort -r (reverses the order)
sort -b (ignore leading blanks)
sort -f (fold case –i.e., be case-insensitive–).

Removing duplicates
unique — removes adjacent duplicated lines
Note: uniq -c — displays unique lines with a count of how often each occurs rather than using uniq and wc
e.g. cut -d, -f2 filename |grep -v Tooth | sort | uniq -c