1833707 Members
2052 Online
110063 Solutions
New Discussion

delete line

 
kamal_15
Regular Advisor

delete line

hi all
how can i delete lines from the fisrt file
to specefic line in this file?
EX:
********************
1111111
2222222
333 hello 3333
4444444
********************
i wnat to delete lines from first line to
line contain word "hello"

many thanks
3 REPLIES 3
Suraj Singh_1
Trusted Contributor

Re: delete line

HI,

Open the file using vi editor,

Two methods:
i) Go to the line upto which you want to delete, and enter following command:-
:1,.d

ii) Find out the line no. of the last line you want to delete, in the above example, hello comes in 3rd line, so enter following command:
:1,3d

Hope this clarifies,

Regards
What we cannot speak about we must pass over in silence.
kamal_15
Regular Advisor

Re: delete line

many thanks for response
iam sorry
i forget to tell u .i want to use sed command

because this procedure is step in my script file.
please help
Ermin Borovac
Honored Contributor

Re: delete line

sed '1,/hello/d'

will delete from the 1st line to line containing "hello" (inclusive).