Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting Columns

Status
Not open for further replies.

gringomike

Technical User
Aug 6, 2003
148
GB
Hi All,

Is there an easy way to count the number of columns from a ps -fu output?

I'm trying to write a script that takes the value of the last column of the ps -fu output but somtimes there are 11 and sometimes there are 12 columns. If there are only 11 columns and my script is hard coded to look for field 12 I could have problems!

I hope this makes sense.

Thanks

GM
 
In awk the last column is $NF.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top