Is there a Linux utility or a Bash command I can use to sort a space delimited string of numbers?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here’s a simple example to get you going:
echo "81 4 6 12 3 0" | tr " " "\n" | sort -gtrtranslates the spaces delimiting the numbers, into carriage returns, because sort uses carriage returns as delimiters (ie it is for sorting lines of text). The-goption tells sort to sort by “general numerical value”.man sortfor further details aboutsort.