Print columns with awk
Print the 1st and 3rd fields of each line. By default awk splits on spaces, so for /etc/passwd you need -F: to split on colons.
awk '{print $1, $3}' /etc/passwd
More linux commands
-
awk '{sum += $2} END {print sum}' file.txtAdd up the values in column 2 of a text file.
-
sed -i '/^#/d' config.confDelete all comment lines that start with # directly in the file.
-
sed -n '/START/,/END/p' file.txtPrint the block of text from START to END, including the marker lines.
-
sort file.txt | uniq -c | sort -rnCount how many times each unique line appears, most frequent first.
-
who -H && wShow active user sessions and what each user is running.