What does `sort -t' ' -rn +2 -3` do in thi

2019-09-05 22:55发布

问题:

I have below code snippet written by someone but I don't understand what sort -t' ' -rn +2 -3 does.

ps aux|tr -s ' '|cut -f1-3,11 -d' '|grep $USER|sort -t' ' -rn +2 -3|cut -f2 -d' '|head -5

Especially +2 and -3 options. I know -r is for reverse and -n is for numbers.

回答1:

The command does a lot of unnecessary work. You can replace it by the following command using pgrep:

pgrep -U"$USER" | sort -r | head -5

Btw, in order to simply understand what sort -t' ' -rn +2 -3 means, you should follow the comment from @1_CR below your question.