User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 456,444 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,633 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 795 | Replies: 5
Reply
Join Date: Aug 2007
Posts: 27
Reputation: skelly16 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
skelly16 skelly16 is offline Offline
Light Poster

Help to sort my script output?

  #1  
Nov 29th, 2007
Hi Guys

I have created a script and everything works but i want my script to sort by the highest count etc.

The script counts the amount of times a job fails , for example the output looks like this:

u08.joebloggs.ndm has failed 1 times
u09joeblogs.rpt has failed 5 times
u10.joeblogs.fw has failed 1 times

How can i get the script to sorted it but the highest amount of times failed.

do i have to use nawk some how, nawk print $ 4 then sort maybe???

Any ideas would be great
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2006
Posts: 1,509
Reputation: masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light 
Rep Power: 10
Solved Threads: 136
masijade's Avatar
masijade masijade is offline Offline
Posting Virtuoso

Re: Help to sort my script output?

  #2  
Nov 29th, 2007
scriptname.sh | sort +3nr
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Join Date: Aug 2007
Posts: 27
Reputation: skelly16 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
skelly16 skelly16 is offline Offline
Light Poster

Re: Help to sort my script output?

  #3  
Nov 29th, 2007
Hi

The data is emailed to me so its all held here

cat $HOME/scripts/autoinfo1.txt | mailx -s "job failure" joeblogg@hotmail.com

that sort command doesnt work against the script, or if i pipe after i cat the file.
Reply With Quote  
Join Date: Feb 2006
Posts: 1,509
Reputation: masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light 
Rep Power: 10
Solved Threads: 136
masijade's Avatar
masijade masijade is offline Offline
Posting Virtuoso

Re: Help to sort my script output?

  #4  
Nov 29th, 2007
cat $HOME/scripts/autoinfo1.txt | sort +3nr | mailx -s "job failure" joeblogg@hotmail.com
Last edited by masijade : Nov 29th, 2007 at 9:46 am. Reason: And I hope that's not the real mail address. Spambots here we come.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Join Date: Aug 2007
Posts: 27
Reputation: skelly16 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
skelly16 skelly16 is offline Offline
Light Poster

Re: Help to sort my script output?

  #5  
Nov 29th, 2007
excellent it work, thanks alot

so what does the sort +3nr mean??
Reply With Quote  
Join Date: Aug 2007
Posts: 27
Reputation: skelly16 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
skelly16 skelly16 is offline Offline
Light Poster

Re: Help to sort my script output?

  #6  
Nov 29th, 2007
got it skip the first 3 fields then sort numerically reverse order, cheers
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Shell Scripting Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 1:50 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC