Operating System - Linux
1828243 Members
2683 Online
109975 Solutions
New Discussion

Vi or editor command need your help

 
SOLVED
Go to solution
Nguyen Anh Tien
Honored Contributor

Vi or editor command need your help

Hi all
I have a file (2570 line ) this is a part of it:
=======
44890236177031.300001 VN0010002 LD0714500064 61925 VND 20070901 51001 21054
144890236177031.320001 VN0010002 LD0714500065 61925 VND 20070901 51001 21054
144890236177031.340001 VN0010002 LD0714500065 61925 VND 20070901 51001 21054
144890236177031.360001 VN0010002 LD0714500065 61925 VND 20070901 51001 21054 PAGE 7 09:09:51 21 NOV 2007

144890236177040.030001 VN0010006 LD0714600019 100000 VND 20070901 51001 21050
144890236177041.000001 VN0010006 LD0714600019 100000 VND 20070901 51001 21050
144890236177041.020001 VN0010011 LD0714600024 161667 VND 20070901 51001 21060
144890236177041.040001 VN0010011 LD0714600024 161667 VND 20070901 51001 21060 PAGE 9 09:09:51 21 NOV 2007

144890236177056.160001 VN0010002 LD0714600070 123850 VND 20070901 51001 21054
144890236177056.180001 VN0010002 LD0714600070 123850 VND 20070901 51001 21054
144890236177056.200001 VN0010002 LD0714600071 74310 VND 20070901 51001 21054
PAGE 10 09:09:51 21 NOV 2007
=====

I want to replace all character since "PAGE" to the end of line by blank or space character.
It is hard with me because of the number of page
for ex: PAGE 8, PAGE 9, PAGE 10 and so on

How to do it ???
pls help
Thank
HP is simple
6 REPLIES 6
mobidyc
Trusted Contributor

Re: Vi or editor command need your help

Hello,

i don't know how to replace these characters but you can suppress them by the following command under vi:
:%s/PAGE .*//

whith sed, you can test something similar:
sed 's/PAGE .*//' filename

--
Regards,
Cedrick Gaillard
Best regards, Cedrick Gaillard
Kasper Hedensted
Trusted Contributor

Re: Vi or editor command need your help

Hi,

Use sed:

sed 's/PAGE.*//'


Regards,
Kasper
Dennis Handly
Acclaimed Contributor
Solution

Re: Vi or editor command need your help

Cedrick has a simple way.
If you want to restrict which lines, you can replace the "%" by two marks: 'a,'b
Or a mark and ".": 'a,.

If you think "PAGE" may be on other lines and "PAGE" starts at the beginning, you can anchor it: %s/^PAGE .*$//
You of course can just delete those lines:
:g/^PAGE "/d
OldSchool
Honored Contributor

Re: Vi or editor command need your help

of course, you could always use "grep" instead

grep -v ^PAGE infile > outfile

would remove all lines beginning w/ PAGE in first character pos
Nguyen Anh Tien
Honored Contributor

Re: Vi or editor command need your help

Thank you all
I know how to fix from your reply
The answer is %s/^PAGE .*$//
points is assigned and thread is closed
HP is simple
Nguyen Anh Tien
Honored Contributor

Re: Vi or editor command need your help

Thank you all
Regards
Tienna
HP is simple