The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 07-02-2009
scottn scottn is offline Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,051
Hi.

There may be a better way, but...

Code:
awk 'NF > X { X = NF } END {print X, NR}' my_file
(assumung space as delimeter)

where X is the number of columns and NR is the number of records.

use awk -F to specify a delimeter if it's not a (white)space.