60321

What does `sort -t' ' -rn +2 -3` do in this pipeline?

Question:

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.

Answer1:

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.

Recommend

  • Get all root sites listed in share point Admin center using graph api beta
  • Excel comparison with multiple IFs
  • Converting Negative Decimal To String Loses the -
  • Why do the numeric format strings in C# round the number when not using decimals (F0)?
  • Python functions: Pass global variables if only accessing them?
  • Sending keystrokes from a C# application to a Java application - strange behaviour?
  • How to get a list of all blobs in a repository in Git
  • Use double quote then curly brace in powershell -Command
  • Binding ContextMenu Tag to Owner
  • How can I get process name of specific PID with ps command in alpine
  • Easy Way to Get Averages Based on Names in List
  • Connection pooling with URLConnection?
  • richtextbox to string
  • How do we generate stack trace in TOMCAT?
  • Unicorn and Rails eat up 2x MySQL connections
  • How to enable large page memory for the JVM?
  • garbled css name when styling within UiBinder
  • How to open html table in xls on click of a button
  • JSR-330 support in Picocontainer : @Inject … @Named(\"xxx)
  • Tell Git to stop prompting me for conflicts when none really exist?
  • Insert new calendar with SyncAdapter- Calendar API Android
  • Ensure fsync did its job
  • Installing Apache MyFaces 2 on WildFly 8.2.0
  • Jquery UI tool tip close icon
  • Read a local file using javascript
  • Using jQuery closest() method with class selector
  • Display issues when we change from one jquery mobile page to another in firefox
  • Deleting and Updating values from a cusrsor adapter
  • Array.prototype.includes - not transformed with babel
  • Modifying destination and filename of gulp-svg-sprite
  • 'TypeError' while using NSGA2 to solve Multi-objective prob. from pyopt-sparse in OpenMDAO
  • Unanticipated behavior
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • Authorize attributes not working in MVC 4
  • Busy indicator not showing up in wpf window [duplicate]
  • How can i traverse a binary tree from right to left in java?
  • How to Embed XSL into XML
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF