Sort by

recency

|

32 Discussions

|

  • + 0 comments
    sort  -k2 -n -r -t '|' 
    
  • + 0 comments
    sort -t $'|' -k2rn
    

    command sets the field separator to the pipe character |, and then sorts the file based on the values in the second column, in descending numeric order. The -k2 specifies the second column, the r tells sort to sort in reverse order, and the n specifies that a numeric sort should be used for values in that column.

  • + 0 comments
    #!/bin/bash
    rm file.txt > stdout.txt 2> stderr.txt
    while IFS= read -r line || [ -n "$line" ]; do
      echo "$line" >> file.txt
    done
    # -n sort numeric
    # -k column sort
    # -t seperator type
    sort -n -r -k2 -t$'|'< file.txt
    
  • + 0 comments
    #!/bin/bash
    sort -k2nr -t $"|"
    
  • + 0 comments

    sort -t$"|" -r -n -k2