specifically, given your claims, just use the
tail -1
command, which will return the last line in the
file, in this case the one with the number.
more generally, if you know the file is regular
(and the nature of the regularity), you can
probably set up a command or little shell script
to get what you want. if your file is 21 lines in
the form of string, blank, numbers, you could try
head -3 | tail -1
as a base and maybe put something like it in the
body of a for loop, kind of like
for i in 3 6 9 12 15 18 21
do
head -$i | tail -1 >> numbers
done
even more generally, use grep with some regular
expression (depending on the nature of the number
the file contains and whether it's on a line by
itself or whatever..., left as an exercise for the
readers, a few of whom will, no doubt, provide
examples with some optional derision pointed my way.
On Wed, 2009-12-30 at 22:25 -0800, John F. Strazzarino wrote:
> I have a three line text file
>>> This is a test
> blank line
> 123456
>>> The last line of the file is a number and I need just that number....
>> I know that this must be a combo of tail and grep
>> Can anyone help......nothing fancy is needed...
> \\
> Thanks
>> John
>>> _______________________________________________
> sf-lug mailing list
>sf-lug at linuxmafia.com>http://linuxmafia.com/mailman/listinfo/sf-lug> Information about SF-LUG is at http://www.sf-lug.org/