Need to display sorted output on 1 line!


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Need to display sorted output on 1 line!
# 1  
Old 01-17-2007
Need to display sorted output on 1 line!

#!/bin/bash
{ [ $# -ge 1 ] && [ $# -le 5 ]; } || {
echo "Must enter between 1 and 5 parameters"
exit 1
}

for P
do
echo $P >> /tmp/task3
done

echo "SORTED: $(sort -n -r /tmp/task3)"
rm -f /tmp/task3
# 2  
Old 01-17-2007
Remove the quotes around the echo "SORTED:....." line - as long as you don't have whitespace in your passed parameters.

Cheers
ZB
# 3  
Old 01-17-2007
thanks worked!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How do we display specific row of an output from bottom given line number?

I pass a number to my script. Passing "1" below. ./getfile.sh 1 echo "User entered: $1" ls -ltr *.conf | sed -n '$p' I wish to use ls -ltr i.e list files in ascending order of time the latest showing at the bottom of the output. Number 1 should get me the last row of ls -ltr output i.e... (9 Replies)
Discussion started by: mohtashims
9 Replies

2. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies

3. UNIX for Dummies Questions & Answers

To find and display the middle line in a file using single line command.

Hi all, How can i display the middle line of a file using a single line command? (6 Replies)
Discussion started by: Lakme Pemmaiah
6 Replies

4. Homework & Coursework Questions

Display sorted list using sed command

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write a command line that will display a sorted list of logged in users. Just display the username and no other... (5 Replies)
Discussion started by: kofine05
5 Replies

5. Shell Programming and Scripting

Cut the final line of each sorted value

Hi I have file like the below mentioned example. Need some kind of unix script to achive the output. Input: PA|23|2013-01-23|252 PA|23|2013-01-23|264 PA|25|2013-01-22|200 PA|23|2013-01-27|156 PA|23|2013-01-27|002 PA|23|2013-01-27|014 Output: PA|23|2013-01-23|264... (8 Replies)
Discussion started by: anshaa
8 Replies

6. Shell Programming and Scripting

Sort a line and Insert sorted word(s) in a line

Hello, I am looking to automate a task - which is updating an existing access control instruction of a server and making sure that the attributes defined in the instruction is in sorted order. The instructions will be of a specific syntax. For example lets assume below listed is one of an... (6 Replies)
Discussion started by: sanjayroc
6 Replies

7. UNIX and Linux Applications

display which line returns specific output

Hi, I'm trying to figure out a way to find which line in my file.txt with IP addresses: 192.168.0.1 192.178.0.2 etc... returns specific result when I execute command affecting all lines. For example when I run: for line in `cat file.txt`; do snmpget $line done it displays the... (5 Replies)
Discussion started by: svetoslav_sj
5 Replies

8. UNIX for Dummies Questions & Answers

Insert a line in a sorted text file(s)

Hello, I am trying to add a line (usually just a word) to some text files in a directory that are already sorted. I just don't want to run the sort command again because it can take a long time when the text or log files are really huge. I have a bashscript that will take in the 1st argument... (7 Replies)
Discussion started by: raptor25
7 Replies

9. UNIX for Dummies Questions & Answers

write a program in c in unix that display the files(includ sub-direc and files within) in a sorted

the sorting is based on name of file, file size modification time stamps o f file it should dislay the output in the following format "." and ".." enteries should be ignored please give some idea how to do it (1 Reply)
Discussion started by: pappu kumar jha
1 Replies

10. UNIX for Dummies Questions & Answers

Command display output on console and simultaneously save the command and its output

Hi folks, Please advise which command/command line shall I run; 1) to display the command and its output on console 2) simultaneous to save the command and its output on a file I tried tee command as follows; $ ps aux | grep mysql | tee /path/to/output.txt It displayed the... (7 Replies)
Discussion started by: satimis
7 Replies
Login or Register to Ask a Question