Home Man
Search
Today's Posts
Register

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

# of rows and columns

Tags
shell scripts

Login to Reply

 
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).
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Rows to columns jimmyf UNIX for Beginners Questions & Answers 6 01-09-2017 01:56 PM
Compare 2 csv files by columns, then extract certain columns of matcing rows bkane3 Shell Programming and Scripting 5 06-04-2014 04:29 AM
Columns and rows shelllearner Shell Programming and Scripting 3 03-20-2014 05:43 AM
Evaluate 2 columns, add sum IF two columns match on two rows mtucker6784 Shell Programming and Scripting 6 08-07-2013 12: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 04:37 AM
Columns to Rows sameeribraimo Windows & DOS: Issues & Discussions 1 07-13-2012 12:33 AM
Rows into Columns greycells Shell Programming and Scripting 1 05-08-2011 11:57 PM
rows to columns suresh3566 Shell Programming and Scripting 3 03-10-2011 03:54 AM
Columns into rows Ramya_1104 Shell Programming and Scripting 1 05-17-2010 04:10 AM
Columns to rows mgirinath Shell Programming and Scripting 16 11-29-2007 06:03 PM


All times are GMT -4. The time now is 08:22 AM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password