UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old December 20th, 2004, 10:57 AM
chrs0302 chrs0302 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 43 chrs0302 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 30 sec
Reputation Power: 4
Command to find colums from the output

Hi

I want to know is there any command in Soalris which gives the number of columns for the output of any commnad. For example if I want to just check the number of columns from the generated output of uptime commnad, this must help me to find out.Of course we can check this from the man pages. But I am searching for a command.

Thanks

Reply With Quote
  #2  
Old December 20th, 2004, 12:19 PM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,307 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 4 h 28 m 57 sec
Reputation Power: 48
There isn't a command that does this. You'll have to write a simple script.

For commands that return a bunch of lines you probably should try awk, this example will work for one-liners as well, but it's not efficient

Code:
cols =`<command> | awk 'BEGIN {maxcol=0}
               { if (NF > maxcol)
                 {
                    maxcol=NF
                 }
               } END {print maxcol} '  `
echo $cols

Last edited by jim mcnamara : December 20th, 2004 at 12:21 PM. Reason: didn't make it return number of columns

Reply With Quote
  #3  
Old December 21st, 2004, 02:48 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,083 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 49 m 57 sec
Reputation Power: 9
try: man wc

Reply With Quote
  #4  
Old January 14th, 2005, 01:42 PM
chrs0302 chrs0302 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 43 chrs0302 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 30 sec
Reputation Power: 4
Columns from a command

Hi Jim and guggach

Sorry for the late reply. I appreciate your help and it helped me a lot.

Thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Command to find colums from the output


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway