Hi,
I have written a one-liner script to count the # of rows and coulmns for a file, like this:
% more dim
if [ $# -eq 0 ]
then
echo "Usage: dim filename"
exit
fi
awk 'BEGIN{FS="\t"} {nfe=NF} END{print NR " " nfe}' $1
This works fine on small files. e.g.
% dim smallfile.ped
2300 3481
However, it does not appear to work for larger files. e.g. for an example file with 2300 rows and 20924 columns ("largefile.ped") i obtain the following:
% dim largefile.ped
2301 0
Could anyone suggest what is going wrong here? It appears to me that awk is counting an extra line & therefore the built-in variable NF counts zero fields for this empty record. However, i know the file has 2300 records, not 2301 - i have checked usiing vi!
Any advise would be appreciated,
Toby
I have written a one-liner script to count the # of rows and coulmns for a file, like this:
% more dim
if [ $# -eq 0 ]
then
echo "Usage: dim filename"
exit
fi
awk 'BEGIN{FS="\t"} {nfe=NF} END{print NR " " nfe}' $1
This works fine on small files. e.g.
% dim smallfile.ped
2300 3481
However, it does not appear to work for larger files. e.g. for an example file with 2300 rows and 20924 columns ("largefile.ped") i obtain the following:
% dim largefile.ped
2301 0
Could anyone suggest what is going wrong here? It appears to me that awk is counting an extra line & therefore the built-in variable NF counts zero fields for this empty record. However, i know the file has 2300 records, not 2301 - i have checked usiing vi!
Any advise would be appreciated,
Toby