Re: awk global replacement only after keyword

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Joseph L. Casale wrote:
>> Can you use a regexp like:
>> s/\(known_part\)\(.*\)\(change_part\)/\1\2replace_part/
> 
> Unless I misunderstand that, I'd say no.
> 
> The actual file might look this:
> 
> /begin file
> 
> foo bar{
> 	biz	service-one
> 	baz	service-two
> }
> 
> --many more of that--
> 
> # comment
> 
> fiz bir{
> 	aaa	service-one
> 	bbb	service-two
> }
> 
> /end file
> 
> So only after the "# comment", I want to then start replacing.
> I am just trying to replace a very ugly long set of commands piped into
> each other that I am using now.

I think there is a way to do it in sed using the holding space, but it's so much 
easier in perl that I never bothered to learn the hard parts.  What's the 
problem with using perl anyway?

-- 
   Les Mikesell
    lesmikesell@xxxxxxxxx

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux