RE: Inserting Text In Specific Location Using Shell Script
- From: "Cesar Covarrubias" <cesar@xxxxxxx>
- Date: Sun, 28 May 2006 18:01:26 -0700
Hello,
Thanks to all who replied. Michael's suggestion was the easiest to
implement, and it worked well.
Very Respectfully,
Cesar Covarrubias
-----Original Message-----
From: redhat-list-bounces@xxxxxxxxxx [mailto:redhat-list-bounces@xxxxxxxxxx]
On Behalf Of Michael Velez
Sent: Friday, May 26, 2006 1:10 PM
To: 'General Red Hat Linux discussion list'
Subject: RE: Inserting Text In Specific Location Using Shell Script
-----Original Message-----
From: redhat-list-bounces@xxxxxxxxxx
[mailto:redhat-list-bounces@xxxxxxxxxx] On Behalf Of Cesar Covarrubias
Sent: Friday, May 26, 2006 3:51 PM
To: General Red Hat Linux discussion list
Subject: Inserting Text In Specific Location Using Shell Script
Hello,
I am running a script on about 30 machines and need to insert
text after a specific comment. For example:
#comment 1
#comment 2
#comment 3
I want to add text after #comment 2, on a new line. I have
been trying to work with both sed and awk but no success.
This has to be done in bash or sh and cannot be done in any
other language. Any ideas?
--
Very Respectfully,
Cesar Covarrubias
cesar@xxxxxxx
You can do this with sed. The trick is to use the 's' command in sed and
actually add a real newline in the substitution field. But the newline
needs to be preceded by a '\'. The script then contains two lines.
Here is a sample sed script which will add a line '#Addendum to comment 2'
right below '#comment 2':
s/#comment 2/#comment 2\
#Addendum to comment 2/
The output of this script executed on the example you gave us is:
#comment 1
#comment 2
#Addendum to Comment2
#comment 3
Hope this helps,
Michael
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
- References:
- RE: Inserting Text In Specific Location Using Shell Script
- From: Michael Velez
- RE: Inserting Text In Specific Location Using Shell Script
- Prev by Date: Re: Installing perl-suid
- Next by Date: server hangs!
- Previous by thread: RE: Inserting Text In Specific Location Using Shell Script
- Next by thread: Re: Inserting Text In Specific Location Using Shell Script
- Index(es):
Relevant Pages
- Re: Placing an HTML file wont work right FP2002
... So you script functions must be moved from ... > I have made an html
page and loaded into my site. ... > site--in other words inserting this exact page from
www.donnamcmenamin.com) onto a background page ... > The html page works fine by itself, all
image maps and rollovers are functioning (as soon as I ... (microsoft.public.frontpage.client) - DBI quote() seems to replace double quotes with two single quotes
... I'm running a script where I'm inserting some values into a MySQL ...
the database and the problem it's causing me is that it seems to ... replace double quotes
with two single quotes. ... (perl.beginners) - Re: Using Java Script Navigation with Dynamic Web Template
... Inserting a script on a DWT, is the same as inserting the script on each individual
page, just that ... > I used a Java Script Switch menu on my web site, ... I
thought DWT ... (microsoft.public.frontpage.client) - Re: ajax & php & javascript
... do with inserting the script via innerHTML and the script blocks don't get processed
when doing that. ... If you want to execute script blocks, then you will have to use a different
method of inserting it in the page to get the browser - any browser - to execute the script.
... The only browser I recall that executed script's inserted via innerHTML was NS6. ...
(comp.lang.javascript) - Re: Inserting Text In Specific Location Using Shell Script
... Cesar Covarrubias wrote: ... I am running a script on about 30 machines
and need to insert text after ... Some prerequisites: ... (RedHat)