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

2019-09-05 22:27发布

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条回答
神经病院院长
2楼-- · 2019-09-05 23:05

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.

查看更多
登录 后发表回答