Formating Output: Difference between revisions
From mylearnings
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 9: | Line 9: | ||
</pre> | </pre> | ||
* For making a structured table out of text and filter our specific info. | |||
<pre> | <pre> | ||
sudo docker images | awk -F ' ' 'NR==, NR==12 {print $3}' | sudo docker images | awk -F ' ' 'NR==, NR==12 {print $3, NR-1}' | ||
</pre> | </pre> | ||
::- sudo docker images => Prints the current docker images in the system. | ::- sudo docker images => Prints the current docker images in the system. | ||
::- -F ' ' => Field separation is set to space. | ::- -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.