bash - Is there a command that works for command line arguments like the sort command does for files? -


i trying write script in bash take between 1 , 5 command line arguments user , report them in reverse numerical order standard output. command know work sort command, works files. there similar command sorting command line arguments? here have far.

#!/bin/bash if [ $# -lt 1 ] || [ $# -gt 5 ]; echo "incorrect number of arguments!" else      sorted=sort -rn $*      echo "sorted: $sorted" fi 

try:

sorted=$( printf '%s\n' "$@" | sort -rn ) printf '%s\n' "${sorted//$'\n'/ }" 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -