Extract using sed

Given a file with contents

 /arch/powerpc/boot/4xx.o
> /arch/powerpc/boot/.4xx.o.cmd
> /arch/powerpc/boot/addnote
5766a5769
> /arch/powerpc/boot/.addnote.cmd
5768a5772,5773
> /arch/powerpc/boot/bamboo.o
> /arch/powerpc/boot/.bamboo.o.cmd
5769a5775,5778
> /arch/powerpc/boot/cpm-serial.o
> /arch/powerpc/boot/.cpm-serial.o.cmd

I want to remove lines ending with *.o and *.o.cmd and redirect to another file.

Can anyone suggest a sed command for this?

better google it . you can solve it easily by using redirection

 
awk '! /o$|o.cmd$/ {print} ' inputfile > outputfile
1 Like

thanks a bunch!:b:

Hi,
Try this one,

 egrep -v '.o|o.cmd' inputfile >outputfile

Cheers,
Ranga:)

1 Like
$ egrep -v ".o$|.o.cmd$" test
> /arch/powerpc/boot/addnote
5766a5769
> /arch/powerpc/boot/.addnote.cmd
5768a5772,5773
5769a5775,5778
1 Like

ya right.., thanks mate:)

1 Like

Also to remove lines ending with ".order"

how will i change command?

awk '! /o$|o.cmd$|.order$/ {print} ' inputfile > outputfile
 
egrep -v ".o$|.o.cmd$|.order$" inputfile > outputfile

1 Like