Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

sort vs sort -n

hi,

what is difference between
sort vs sort -n  vs sort -M vs sort -rM

please advise
Avatar of ozo
ozo
Flag of United States of America image

man sort
     -M
             Sort by month abbreviations.  Unknown strings are considered smaller than the month names.

     -n
             Sort fields numerically by arithmetic value.  Fields are supposed to have optional blanks in the beginning, an optional minus sign, zero or more digits
             (including decimal point and possible thousand separators).
    -r
             Sort in reverse order.



e.g.
(echo "Jan"; echo "Feb"; echo "Mar"; echo "1"; echo "11"; echo "2"; echo "22") | sort
(echo "Jan"; echo "Feb"; echo "Mar"; echo "1"; echo "11"; echo "2"; echo "22") | sort -n
(echo "Jan"; echo "Feb"; echo "Mar"; echo "1"; echo "11"; echo "2"; echo "22") | sort -M
(echo "Jan"; echo "Feb"; echo "Mar"; echo "1"; echo "11"; echo "2"; echo "22") | sort -rM
SOLUTION
Avatar of Prabhin MP
Prabhin MP
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

bash-4.4$ ls -ltr                                                                                                                                  
total 8                                                                                                                                            
-rw-r--r-- 1 13381 13381 978 Nov  9 20:39 README.txt                                                                                              
-rw-r--r-- 1 13381 13381   0 Nov  9 20:39 xyz.txt                                                                                                  
-rw-r--r-- 1 13381 13381  24 Nov  9 20:40 xyx.txt                                                                                                  
-rw-r--r-- 1 13381 13381   0 Nov  9 21:30 errors.txt                                                                                              
bash-4.4$ sort                                                                                                                                    



i tried as above here
https://www.tutorialspoint.com/unix_terminal_online.php

i see it is taking forever to give result

please advise
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial