Skip to content

Instantly share code, notes, and snippets.

@caiguanhao
Last active August 29, 2015 14:12
Show Gist options
  • Save caiguanhao/b6b94b43143b39e96f35 to your computer and use it in GitHub Desktop.
Save caiguanhao/b6b94b43143b39e96f35 to your computer and use it in GitHub Desktop.

Move NAMES to first column

dpsa | awk 'NR==1{I=index($0,"NAMES");J=length($0);K=substr($0,I);L=substr($0,0,I-1)}NR==2{print K sprintf("%*s",length($0)-J,"") L}NR>1{print substr($0,I)substr($0,0,I-1)}' | less -XSF

Move NAMES after CONTAINER ID before IMAGE

dpsa | awk 'NR==1{A=index($0,"IMAGE");B=substr($0,0,A-1);C=index($0,"NAMES");D=substr($0,A,C-A-1);E=length($0);F=substr($0,C)}NR==2{print B F sprintf("%*s",length($0)-E,"") D}NR>1{print substr($0,0,A-1)substr($0,C)substr($0,A,C-A-1)}' | less -XSF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment