# of rows and columns

Tags
shell scripts

 
Thread Tools Search this Thread
# 1  
Old 07-02-2009
# of rows and columns

Hi,

Does anyone know the command to know the # of rows and columns for a file?

thanks
# 2  
Old 07-02-2009
depends on your 'file' (whatever it is) format.......
# 3  
Old 07-02-2009
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.
# 4  
Old 07-02-2009
Quote:
Originally Posted by kylle345
Hi,

Does anyone know the command to know the # of rows and columns for a file?

thanks
See here(example 9) for example (assuming space separated).

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Rows to columns dsid Shell Programming and Scripting 1 04-27-2017 08:05 AM
Rows to columns jimmyf UNIX for Beginners Questions & Answers 6 01-09-2017 02:56 PM
Compare 2 csv files by columns, then extract certain columns of matcing rows bkane3 Shell Programming and Scripting 5 06-04-2014 05:29 AM
Columns and rows shelllearner Shell Programming and Scripting 3 03-20-2014 06:43 AM
Combining rows into columns Selva_2507 Shell Programming and Scripting 9 12-03-2013 08:43 PM
Columns to rows apenkov Shell Programming and Scripting 11 11-27-2013 08:27 PM
Evaluate 2 columns, add sum IF two columns match on two rows mtucker6784 Shell Programming and Scripting 6 08-07-2013 01:57 PM
Deleting all the fields(columns) from a .csv file if all rows in that columns are blanks ks_reddy Shell Programming and Scripting 4 02-04-2013 05:37 AM
Rows to Columns rakesh5300 Shell Programming and Scripting 6 12-21-2012 02:47 AM
Columns to Rows sameeribraimo Windows & DOS: Issues & Discussions 1 07-13-2012 01:33 AM
Rows into Columns greycells Shell Programming and Scripting 1 05-09-2011 12:57 AM
rows to columns suresh3566 Shell Programming and Scripting 3 03-10-2011 04:54 AM
Rows into columns? regexnub Shell Programming and Scripting 8 06-07-2010 11:29 PM
Columns into rows Ramya_1104 Shell Programming and Scripting 1 05-17-2010 05:10 AM
Columns to rows mgirinath Shell Programming and Scripting 16 11-29-2007 07:03 PM