Formating Output: Difference between revisions

From mylearnings
Jump to navigationJump to search
Created page with "<pre> <command> | uniq </pre> ::- Prints only unique line."
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
* Prints only unique line.
<pre>
<pre>
<command> | uniq
<command> | uniq
</pre>
</pre>
::- Prints only unique line.
 
* Sorts the lines.
<pre>
<command> | sort
</pre>
 
* For making a structured table out of text and filter our specific info.
<pre>
sudo docker images | awk -F ' ' 'NR==, NR==12 {print $3, NR-1}'
</pre>
::- 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.

Latest revision as of 10:54, 16 June 2025

  • 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.