How to get number of lines from a file into a shell variable [message #98128] |
Fri, 19 March 2004 11:16 |
Swamy
Messages: 78 Registered: June 2002
|
Member |
|
|
To get number of lines from a data file into a shell variable, I wrote as below in my shell script.
$countlines=`wc -l datafile.dat`
$echo countlines=$countlines
The result I am getting is:
$countlines= 4567 datafile.dat
I need only the number 4567 as output, but not with the string datafile.dat. How can I achieve? I appreciate in advance for your help.
Thanks
Raj
|
|
|
|
|
|
|
|