Re: [CentOS] sed question

2015-08-25 Thread James A. Peltier
- Original Message - | I am trying to use sed to change a value in a pipe. | | --- This is the two line script | CHANGE=1234 | | cat my_file.txt | sed 's/CANCELID/$CHANGE/' cancel.txt | --- | | and the my_file.txt has: |

Re: [CentOS] sed question

2015-08-25 Thread Gordon Messmer
On 08/25/2015 10:50 AM, Jerry Geis wrote: cat my_file.txt | sed 's/CANCELID/$CHANGE/' cancel.txt sed doesn't perform environment variable expansion. That is to say that when you instruct sed to substitute $CHANGE for CANCELID, $CHANGE is a literal string that will be substituted. bash,

Re: [CentOS] sed question

2015-08-25 Thread John R Pierce
On 8/25/2015 10:50 AM, Jerry Geis wrote: --- This is the two line script CHANGE=1234 cat my_file.txt | sed 's/CANCELID/$CHANGE/' cancel.txt --- and the my_file.txt has: v1:notificationIdCANCELID/v1:notificationId it gets changed to $CHANGE instead of

Re: [CentOS] sed question

2015-08-25 Thread Larry Martell
On Tue, Aug 25, 2015 at 1:50 PM, Jerry Geis ge...@pagestation.com wrote: I am trying to use sed to change a value in a pipe. --- This is the two line script CHANGE=1234 cat my_file.txt | sed 's/CANCELID/$CHANGE/' cancel.txt --- and the my_file.txt has:

Re: [CentOS] sed question

2015-08-25 Thread Gordon Messmer
On 08/25/2015 11:21 AM, Alice Wonder wrote: cat file.txt |\ sed -e s?foo?bar?g |\ sed -e s?dirty?clean? |\ file2.txt I don't understand why you'd quote that way. Though unlikely, you could potentially match a filename in the working directory, and hose the sed command. For

Re: [CentOS] sed question

2015-08-25 Thread Alice Wonder
On 08/25/2015 11:02 AM, Gordon Messmer wrote: Additionally, you can avoid using cat to make the script more efficient. You'll start fewer processes, and complete more quickly. cat is almost never needed unless you actually need to concatenate multiple files. I sometimes like to use cat

Re: [CentOS] sed with several lines, how?

2010-11-27 Thread Arthur Bela
thank you, and sorry, if i had formulated wrong, but the SOMETEXT#X is a random STRING, like: $ cat testfile.txt alsjflsajfkljasdf brfont size=3asfklasjlkyxcvo/fontbr brfont size=3kldfjlkasjdfasdf/fontbr kasfjxcvklajdflas yxcvkjasafjads brfont size=3asdfjkldjlasj/fontbr /font/div/body/html

Re: [CentOS] sed with several lines, how?

2010-11-27 Thread Christopher Chan
Hahahaha, I see that you posted this in quite a few places. Let me repeat it here then. BTW, do a bit of homework if you do need fine tuning before posting back on this list. awk 'BEGIN {sawpattern=0} ^[[:alpha:]], ^[[:alpha:]] {if (($0 ~/brfont size=3[[:alpha:]]/ ) (sawpattern == 0))

Re: [CentOS] sed a particular line in file

2010-04-10 Thread Tom Brown
% cat foo Hello line 1 Hello line 2 Hello line 3 # To change just line 2 % sed '2s/Hello/There/' Hello line 1 There line 2 Hello line 3 # To change line 2 and onwards % sed '2,$s/Hello/There/' Hello line 1 There line 2 There line 3 It's that simple :-) yes indeed - simples

Re: [CentOS] sed a particular line in file

2010-04-09 Thread Stephen Harris
I thought i could use sed to change a particular line number but i dont see that in the man page, i am trying to change a value from line number 6 % cat foo Hello line 1 Hello line 2 Hello line 3 # To change just line 2 % sed '2s/Hello/There/' Hello line 1 There line 2 Hello line 3 # To

Re: [CentOS] sed help

2010-03-09 Thread Dan Burkland
-Original Message- From: centos-boun...@centos.org [mailto:centos-boun...@centos.org] On Behalf Of Paul Heinlein Sent: Tuesday, March 09, 2010 11:08 AM To: CentOS mailing list Subject: Re: [CentOS] sed help On Tue, 9 Mar 2010, chloe K wrote: Hi Can I know how to use sed

Re: [CentOS] sed (or other) magic to get RPM base names ?

2009-09-21 Thread Ralph Angenendt
On Mon, Sep 21, 2009 at 3:06 PM, Alan McKay alan.mc...@gmail.com wrote: avahi-0.6.16-1.el5 avahi-glib-0.6.16-1.el5 produce this : avahi avahi-glib r...@knodd:~# rpm -qa --queryformat %{name}\n avahi\* avahi avahi-compat-libdns_sd avahi-glib r...@knodd:~# Ralph

Re: [CentOS] sed (or other) magic to get RPM base names ?

2009-09-21 Thread Christoph Maser
Am Montag, den 21.09.2009, 15:06 +0200 schrieb Alan McKay: Hey folks, Once upon a time I saw some sed magic to take the output of rpm -qa and strip away all the version info to give just the RPM base names. And of course I forgot to note it :-/ And have not been able to replicate it

Re: [CentOS] sed append question

2009-08-19 Thread Filipe Brandenburger
Hi, On Wed, Aug 19, 2009 at 13:24, Joseph L. Casalejcas...@activenetwerx.com wrote: Hey guys, I am trying to make sed append every line containing a string with another line. problem is the appended line needs to start with a tab: # sed -i '/string/a \tstuff\t\t\tmorestuff' file Obviously

Re: [CentOS] sed append question

2009-08-19 Thread Joseph L. Casale
The a command expects to be followed by a \, so it's eating the one in your first \t. If you add another \ it seems to work as you want it to: $ echo string | sed '/string/a \\tstuff\t\t\tmorestuff' string stuff morestuff $ Ah ffs, lol... It would also help if I emailed

Re: [CentOS] sed append question

2009-08-19 Thread Filipe Brandenburger
Hi, On Wed, Aug 19, 2009 at 16:20, Joseph L. Casalejcas...@activenetwerx.com wrote: '/string/a \\tstuff\t\t\tmorestuff' != /string/a \\tstuff\t\t\tmorestuff Yes, indeed... The rules of quoting and backslashes in the shell are not very uniform and can get quite tricky... Also, the \t is

Re: [CentOS] sed

2008-05-23 Thread Matt Shields
On Fri, May 23, 2008 at 11:41 AM, Scott McClanahan [EMAIL PROTECTED] wrote: Not specific to CentOS but I know you guys would be really helpful anyhow. Basically, I have a file which has been editted in the past very similarly to the hosts file only now I want to use it as a hosts file and need

Re: [CentOS] sed

2008-05-23 Thread Mihai T. Lazarescu
On Fri, May 23, 2008 at 08:41:19AM -0700, Scott McClanahan wrote: Not specific to CentOS but I know you guys would be really helpful anyhow. Basically, I have a file which has been editted in the past very similarly to the hosts file only now I want to use it as a hosts file and need to run

Re: [CentOS] sed

2008-05-23 Thread Stephen Harris
On Fri, May 23, 2008 at 06:02:29PM +0200, Mihai T. Lazarescu wrote: On Fri, May 23, 2008 at 08:41:19AM -0700, Scott McClanahan wrote: 1.1.1.1foo 10.10.10.10bar bar2 100.100.100.100foobar foobar2 foobar3 == After == 1.1.1.1foo.contoso.com 10.10.10.10

Re: [CentOS] sed

2008-05-23 Thread Thomas Johansson
Stephen Harris wrote: On Fri, May 23, 2008 at 06:02:29PM +0200, Mihai T. Lazarescu wrote: On Fri, May 23, 2008 at 08:41:19AM -0700, Scott McClanahan wrote: 1.1.1.1foo 10.10.10.10bar bar2 100.100.100.100foobar foobar2 foobar3 == After == 1.1.1.1

Re: [CentOS] sed

2008-05-23 Thread Stephen Harris
On Fri, May 23, 2008 at 06:59:24PM +0200, Thomas Johansson wrote: Stephen Harris wrote: sed 's/^\([^]*[ ]*[^]*\)\([ ]*.*\)$/\1.contoso.com\2/' (where there's a space *and* a TAB inside each of the [ ] ) The above version easier to read and copy paste. Space is space

Re: [CentOS] sed

2008-05-23 Thread MHR
On Fri, May 23, 2008 at 8:50 AM, Matt Shields [EMAIL PROTECTED] wrote: I'd use awk. Put the lines in a file, then do this cat test.txt | awk '{ print $1 \t $2 .centos.com\t $3 \t $4 }' Or just awk '{ print $1 \t $2 .centos.com\t $3 \t $4 }' test.txt newhostsfile (The cat just complicates

Re: [CentOS] sed

2008-05-23 Thread Les Mikesell
Stephen Harris wrote: On Fri, May 23, 2008 at 06:59:24PM +0200, Thomas Johansson wrote: Stephen Harris wrote: sed 's/^\([^]*[ ]*[^]*\)\([ ]*.*\)$/\1.contoso.com\2/' (where there's a space *and* a TAB inside each of the [ ] ) The above version easier to read and copy