Simple Bash Sort Script

Bash is a unix shell discussion forum. Share your ideas, experience etc....
  • Advertisement

Simple Bash Sort Script

Postby Emerson M » Wed Oct 24, 2012 5:42 am

Simple Bash Sort Script

Simple bash script that sorts a series of numeric parameters using a temporary file and sort command.

Code: Select all
    #!/bin/sh
    # Simple Sort Script By Ben
    for f in $@
    do
    # Store parameters in temp file
    echo $f >> sortme.tmp
    done
    # Sort temp file
    for f in `cat sortme.tmp | sort -n`
    do
    f2="$f2 $f"
    done
     
    # Delete temp file
    rm sortme.tmp
     
    # Show output
    echo $f2
Emerson M
Posting Frequency
Posting Frequency
 
Posts: 1058
Joined: Wed Oct 24, 2012 5:14 am

Advertisement

Simple Bash Sort Script

Return to Bash


Link to: Simple Bash Sort Script
URL:
BBCODE:
HTML:

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 0 guests

 ® PcLayer.com 2009-2012 ©   All Rights Reserved

cron