[Prev][Next][Index][Thread]
Re: a sed question...
On Mon, 17 Feb 1997, Moshe Cohen wrote:
> $N=="<hr size=\"2\">" \
> { print "<!--#include virtual=\"/bottom.raw\" -->"; done = 1}
> {if (done==0) print}
>
> I assume here that <hr size="2"> only occurs at the beginning of
> this block.
>
or you could use head to cut the last ten lines, using wc and bc (isn't
there arithmetic evaluation in bash? oh, well) to do the math):
-------------------------------------------
#!/bin/sh
LINES_TO_CUT=10
LINES_IN_FILE=`wc -l $1|awk '{print $1}'`
head -`echo "$LINES_IN_FILE-$LINES_TO_CUT" | bc` $1
echo "text to insert instead"
-------------------------------------------
$1 is the file to slice.
I'm sure you can embed line 5 ("LINES_IN...") in line 6 to get a more
compact unixfreak-like script but my sh arithmetic fails at this point :)
Eli
References: