1837205 Members
2468 Online
110115 Solutions
New Discussion

vi-editor

 
Veera.Rao
Frequent Advisor

vi-editor

Hi,

I have 200 lines in a file. Now i need to deleted some lines in between the file.

for example: from 99th line to 150th line

how to delete using vi editor or any other method to do this.....please help me


Regards,
Veera

8 REPLIES 8
Steven E. Protter
Exalted Contributor

Re: vi-editor

Shalom Veera,

99
51dd

http://www.eng.hawaii.edu/Tutor/vi.html

http://www.gnulamp.com/vi.html

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor

Re: vi-editor

Hi:

In 'vi' position the cursor on the 99th line (type escape, :99) and enter '51dd' to delete the next 51-lines.

You can use 'sed':

# sed -e '99,150d' file > file.new

Regards!

...JRF...
Veera.Rao
Frequent Advisor

Re: vi-editor

Hi,


i mentioned date and time for beginning
every of line...can you pls tell me how to sort the line in vi editor with date and time
James R. Ferguson
Acclaimed Contributor

Re: vi-editor

Hi Veera:

> i mentioned date and time for beginning
every of line...can you pls tell me how to sort the line in vi editor with date and time

Where in your original post did you mention anything about sorting or anything about timestamps?

What are you really trying to accomplish?

What (*exactly*) does your input file look like (post a snippet) and what (*exactly*) do you want to transform it into?

# man sort

...offers a great deal of information. One doesn't 'sort' in 'vi'.

Regards!

...JRF...
Veera.Rao
Frequent Advisor

Re: vi-editor

thanks for your support.
Dennis Handly
Acclaimed Contributor

Re: vi-editor

>delete ... 99th line to 150th line

If you don't want to do complicated arithmetic in your head, you can just use:
:99,150d

If you want to use the visual editor you can mark the first line "ma", then go to the last line and then "d'a".

>tell me how to sort the line in vi editor with date and time

>JRF: One doesn't sort in vi.

Sure you can but you have to know the sort options.

If you want to sort the whole file, on the first line: !Gsort
You can also sort partial ranges using the mark command: !'asort
Suraj K Sankari
Honored Contributor

Re: vi-editor

Hi Veera,

If you got your answer then from next time please assign points to those people who give there valuable time to help you out.
To know how to assign points please go through this below link

http://forums11.itrc.hp.com/service/forums/helptips.do?#33

Suraj
melvyn burnard
Honored Contributor

Re: vi-editor

Also, please open your thread in a relevant sub-forum, none of the questions you have asked have ANYTHING to do with Serviceguard.
My house is the bank's, my money the wife's, But my opinions belong to me, not HP!