LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-17-2004, 08:23 AM   #1
freelinuxcpp
Member
 
Registered: Jul 2003
Posts: 129

Rep: Reputation: 15
delete some lines from a file


hello every1
i wanna remove some lines from a specific file , in my case it's httpd.conf where i wanna remove the Virtual host lines ( that i already add with a script ) is there any command to do this ?
we have to know that my httpd.conf looks like this :

Code:
...
...
#user1
<VirtualHost 10.0.0.1>
    DocumentRoot /var/www/clients/user1
    ServerName www.yahoo.com
</VirtualHost>
...
...
thnx for any suggestions !
 
Old 01-17-2004, 10:07 AM   #2
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Rep: Reputation: 45
try vimtutor

it'll teach you much about editing files with vim
 
Old 01-17-2004, 10:08 AM   #3
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 68
If you want to automate the process then sed is probably the way to go.
 
Old 01-17-2004, 10:17 AM   #4
dishawjp
Member
 
Registered: Dec 2003
Location: Central New York
Distribution: RH/Fedora/SUSE
Posts: 64

Rep: Reputation: 15
You should really learn vi or vim, but to answer your question:

su to root

vi httpd.conf

<esc> (press the escape key)

use the arrow keys to put your cursor at the beginning of the first line you want to delete

type "dd" (less the quotes)

repeat until all lines you wish to remove have been removed

then:

<esc> :wq

Couldn't be a lot simpler than that.

HTH

Jim Dishaw
 
Old 01-17-2004, 10:28 AM   #5
freelinuxcpp
Member
 
Registered: Jul 2003
Posts: 129

Original Poster
Rep: Reputation: 15
i wanna do this by a scrip , i wrote a peace of code for that :

to delete this :
sed -e '/name/d' /etc/apache/httpd.conf
, but i can not use # after <VirtualHost> this cause a bug :'( !

Last edited by freelinuxcpp; 01-18-2004 at 02:28 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
erase all the lines of a file Prasun1 Linux - General 9 11-06-2005 10:53 AM
How to remove lines from a file doza Linux - General 2 04-27-2005 11:59 AM
vi command to find and delete all lines beginning with a character geomatt Linux - Software 8 12-20-2004 03:30 AM
Tried to delete file as root but it says I don't have permission to delete it! beejayzed Mandriva 23 03-12-2004 02:46 AM
Editior automatically delete content between lines dnla Linux - Newbie 2 10-21-2003 04:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration