/ Published in: Bash
URL: http://www.amugofjava.me.uk/
Simple bash script that sorts a series of numeric parameters using a temporary file and sort command.
Expand |
Embed | Plain Text
#!/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
Comments
Subscribe to comments
You need to login to post a comment.

Example:
./sort.sh 5 8 10 2 5 4 7
Gives the result
2 4 5 5 7 8 10