[KLUG Members] shell

Miles Pschigoda miles.j.pschigoda at wmich.edu
Fri Feb 18 09:18:53 EST 2005


komal wrote:
> Hello
> 
> How to delete certain numbers of line from beginning, middle, or bottom of
> file in Shell?
> 

You could use vim if it is to be interactive.  If you want it scriptable 
and you know what line numbers you want deleted then you can do it with 
an ed script.  There is probably a prettier way of doing it then this, 
but this just popped into my head:

echo "deleting lines 5 to 10"
echo "5,10dw" | ed filename.txt

> How to append last line of output of command to another on specific line in
> Shell?

for this you could try something like:

echo "getting last line from 'command-you-want-line-from'"
command-you-want-line-from | tail --lines=1 >> file-to-append-to.txt

> 
> Thank you
> 
> Komal

Just some ideas, ed and tail both have good man pages too.

MilesP


More information about the Members mailing list