Formating Output

From mylearnings
Jump to navigationJump to search
  • Prints only unique line.
<command> | uniq
  • Sorts the lines.
<command> | sort
  • For making a structured table out of text and filter our specific info.
sudo docker images | awk -F ' ' 'NR==, NR==12 {print $3, NR-1}'
- sudo docker images => Prints the current docker images in the system.
- -F ' ' => Field separation is set to space.
- NR==2 => Start from row 2.
- NR==12 => End at row 12
- {print $3, NR-1} => The command to be executed, Here, print third column based on the field separator and print the line number.