Simple Bash Sort Script


/ Published in: Bash
Save to your folder(s)

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


Copy this code and paste it in your HTML
  1. #!/bin/sh
  2. # Simple Sort Script By Ben
  3. for f in $@
  4. do
  5. # Store parameters in temp file
  6. echo $f >> sortme.tmp
  7. done
  8. # Sort temp file
  9. for f in `cat sortme.tmp | sort -n`
  10. do
  11. f2="$f2 $f"
  12. done
  13.  
  14. # Delete temp file
  15. rm sortme.tmp
  16.  
  17. # Show output
  18. echo $f2

URL: http://www.amugofjava.me.uk/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.