Unix Shell - Finding and changing a paragraph with varying content

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > December 2006 > Finding and changing a paragraph with varying content





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Finding and changing a paragraph with varying content
Charles A. Landemaine

2006-12-10, 7:25 pm

I have a paragraph like this one on a configuration file:

#### fastcgi module
## read fastcgi.txt for more info
#fastcgi.server = ( ".php" =>
# ( "localhost" =>
# (
# "socket" =>
"/tmp/php-fastcgi.socket",
# "bin-path" =>
"/usr/local/bin/php-cgi"
# )
# )
# )

Its content may change, but it always start and ends the same way. I'd
like to know how I can identify this paragraph inside my configuration
file and how to change it with another paragraph such as:

#### fastcgi module
## read fastcgi.txt for more info
#fastcgi.server = ( ".php" =>
# ( "localhost" =>
# (
# "socket" =>
"/tmp/php-fastcgi.socket",
# "bin-path" =>
"/Programs/PHP5/bin/php-cgi"
# )
# )
# )

Remembering that the paragraph to search for can have stuff that
changes over time in the middle of the paragraph.

Thanks,

Michael Paoli

2006-12-11, 1:41 am

Charles A. Landemaine wrote:
> I have a paragraph like this one on a configuration file:
> Its content may change, but it always start and ends the same way. I'd
> like to know how I can identify this paragraph inside my configuration
> file and how to change it with another paragraph such as:


Many ways, e.g. ed(1):
$ cat foo.conf
before
still before
START
stuff
END
after
still after
$ ed foo.conf <<\__EOT__
> /^START$/+1,/^END$/-1c
> new stuff
> more new stuff
> .
> w
> q
> __EOT__

54
73
$ cat foo.conf
before
still before
START
new stuff
more new stuff
END
after
still after
$

Charles A. Landemaine

2006-12-12, 1:37 am

Thank you Michael ;)

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com