Re: Beginner Question (related to homework)



2007-09-24, 14:34(-07), prelim_questions@xxxxxxxxx:
I need to perform a complicated (for me) operation at the command line
using a series of pipes, but not using grep, sed, or awk.

At one point I may have a list as follows:

1.2
3.45
6.7
a
bc


Is there an easy way to count only the numeric lines? I do not know
in advance how many lines are numbers and how many are strictly
alphabetic. There are no mixed lines.
[...]

If it has to be convoluted and not obvious and not legible, you
could do things like:

< list tr -cs 0-9. '[\n*]' | wc -l

of course, that doesn't work if there are lines containing both
alphabetics and numbers, or lines with digits and several dots...

--
Stéphane
.



Relevant Pages