'c' shell scripts - (nf)
jeff at heurikon.UUCP
jeff at heurikon.UUCP
Mon Jan 2 06:32:57 AEST 1984
> From: fair at dual.UUCP (Erik E. Fair)
> I once used `a-truly-ugly-and-evil' way to read successive lines
> of a file for csh. Combinations of head and tail can do the trick:
>
> # To keep the evil sh away...
> set x=1
> while ($x < ????)
> head -$x FILE | tail -1 (or minus however many lines you want)
> end
Sorry Erik, I think you'll have problems with big files. At least
we would because our 'tail' has a bug: if the line number is > 99,
strange things happen. To test, try: "tail -nnn bigfile | wc -l"
And, you've got the same Un*x port that we do...Un*Plus+.
(Let's both report it!)
Ah!, but along the lines of your suggestion there *is* a solution!
I've had good luck using 'sed' instead of the 'head'/'tail' combination.
It's fast and flexible. Try a varient of this:
x=3
oneline=`sed -n $x,"$x"p`
echo $oneline
--
Jeffrey Mattox, Heurikon Corp, Madison, WI
{harpo, hao, philabs}!seismo!uwvax!heurikon!jeff
(That path is correct, desipte what the headers might show.)
More information about the Comp.unix
mailing list