Skip to Content.
Sympa Menu

sm-sorcery - Re: [SM-Sorcery]questions about advanced file manipulation with bash/unix tools.

sm-sorcery AT lists.ibiblio.org

Subject: Discussion of Sorcery related topics

List archive

Chronological Thread  
  • From: Dufflebunk <dufflebunk AT dufflebunk.homeip.net>
  • To: "Nicholas K. Jennings" <nkj AT namodn.com>
  • Cc: sm-sorcery AT lists.ibiblio.org
  • Subject: Re: [SM-Sorcery]questions about advanced file manipulation with bash/unix tools.
  • Date: 31 Jul 2002 02:15:50 -0400

The main tools for doing search and replacement are sed and awk. I've
yet to figure out how to do n-line regexps in them without changing the
IFS environment variable though.
You might find some inspiration in some of my scripts... grimoireToDot
or the distrowatch one particularly use a lot of it... This might help:

awk 'BEGIN{ok_print=0; } /.*Source.*/{ok_print=1; } /Mage/{ok
_print=0; } { if(ok_print==1) print $0; }' some_file

will print every line of a file between "Source" and "Mage".


On Wed, 2002-07-31 at 00:41, Nicholas K. Jennings wrote:
> Hi all,
>
> I have some questions about how to go about doing some advanced file
> editing with bash script and the standard unix tools. Everytime I
> think about how to go about things I get caught up in the perl way
> to do it :)
>
> What I'd like to do is, edit a file, search for a section in that
> file, remove the whole section (several lines), which means being
> able to determin when the section starts, and ends (character
> recognition/regexp?). Then replace that section (in the same
> location) with generated content that I would have already
> generated to replace it.
>
> What tools would be needed to go about doing this? Any pointers,
> tips, examples etc. would be greatly appreciated.
>
> --
> Nicholas K. Jennings | nkj AT namodn.com
> SourceMage GNU/Linux | www.sourcemage.org
> Sorcery Team |
> _______________________________________________
> SM-Sorcery mailing list
> SM-Sorcery AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/sm-sorcery
>
--


Quidquid latine dictum sit, altum sonatur.
-----------------
PGP public key at
http://wwwkeys.ch.pgp.net:11371/pks/lookup?op=get&search=0x92B5D3F1

Attachment: signature.asc
Description: This is a digitally signed message part




Archive powered by MHonArc 2.6.24.

Top of Page