Operating System - HP-UX
1825987 Members
3460 Online
109690 Solutions
New Discussion

Re: sed command or edit output

 
Cliff Lewis
New Member

sed command or edit output

I am trying to use the sed command to remove some lines in a text file. The
lines are like the following
(1 row affected)
(68 rows affected)
The number of rows could change, so is there a wildcard option.
Some lines have the following
-----------
----------------
the length varies.

What command would you use?
sed -e 's/? row affected)//' \
-e 's/?? rows affected)//' \
-e 's/??? rows affected)//' \
infile > outfile

This would work, but if at a later date the rows are > 10000 I will have to
fix. Trying not to do this.

Thanks in advance
2 REPLIES 2
Cliff Lewis
New Member

Re: sed command or edit output

Answer my own question

Use the following command

sed -e /affected/D -e /----/D infile > outfile
Julio Garcia_4
New Member

Re: sed command or edit output

Prove the next instruction:

grep -v "row affected" file | grep -v "rows affected"
> file_new