Moving second row after fourth using awk -


i have task output of:

ps auxfwww | sort -k2n | head -n4 

then have rearrange it, using awk, result 1st,3rd,11th column of rows 2,3,4. rows must in order 3,4,2. closest this:

ps auxfwww | sort -k2n | head -n4 | awk 'nr>=3' | awk '{print $1, $3, $11}' 

but have no idea how row 2 after rows 3 , 4.

it has done single line command.

please shed light :)

ps auxfwww | sort -k2n | head -n4 | awk '{ a[i++] = $1" "$3" "$11 } end { print a[2]; print a[3]; print a[1] }' 

this prints row 3, row 4, followed row 2.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -