LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 08-15-2006, 04:58 AM   #1
Swift&Smart
Member
 
Registered: Jan 2003
Location: Hong Kong,China
Distribution: Slackware,OpenSUSE
Posts: 472

Rep: Reputation: 30
sed and newline problem


Hello everyone.

I am writing a shell script which will facilitate my initial installation of slackware.This shell script will help me to install tomcat and the like.However,when I try to find a text which is something like:

<!--
<server>.....


-->

I want to find the text from <!-- .... to --> and remove it.How can I call it in shell script with command sed?

Thanks a million.
 
Old 08-15-2006, 05:03 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Hi,

Something like this:

sed '/<!--/,/-->/d' infile

Hope this helps.
 
Old 08-15-2006, 06:23 AM   #3
Swift&Smart
Member
 
Registered: Jan 2003
Location: Hong Kong,China
Distribution: Slackware,OpenSUSE
Posts: 472

Original Poster
Rep: Reputation: 30
druuna,thanks for your reply.

sed '/<!--/,/-->/d' infile

Is it a comma after slash?When I tried it in vi to search,it doesn't work.How come?

Thanks anyway.
 
Old 08-15-2006, 06:32 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Hi,

Because vi and sed are not the same. The command given (and asked for) is a sed command.

In vi do the following (in command mode):

:/<!--/,/-->/d

But I'm a bit confused. You said that you want to make a shell script, using sed to remove the mentioned part. What has vi got to do with that?
 
  


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
Sed: insert a newline. Why does not it work? J_Szucs Linux - Software 4 03-19-2014 01:28 PM
Awk newline problem CelticSoul Linux - General 5 05-03-2006 09:00 PM
SED newline usage question -- I think sadarax Linux - General 3 02-18-2006 11:50 PM
newline problem harrylmh Programming 4 11-21-2005 04:04 AM
newline problem between DOS and Unix format cjs_pro Programming 7 03-11-2005 11:08 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration