I’m trying to put the number of lines in a file into an integer variable.
This is how i’m doing it
typeset -i x
x=`wc -l $1`
where $1 is the command line arg
The problem is that wc -l gives a number and the filename like: 5 blah
Is there a way to only put the number into x?
You could do
cat $1 | wc -linstead.Or
wc -l $1 | cut -d " " -f 1.