Loading ...
Sorry, an error occurred while loading the content.

49557Re: >> help with scripting vim

Expand Messages
  • David Rock
    Apr 22, 2004
    • 0 Attachment
      * owen beresford <owencanprogram@...> [2004-04-22 22:14]:
      > On Thu, 22 Apr 2004 15:07:14 -0500, "Sean C. Hubbell" <sch@...>
      > said:
      > > %s!192\.168\.1\.1!192\.168\.1\.2!g
      > >
      > > % - global
      > > s - substitute
      > > . needs to be escaped as it is a special character
      > > ! -just the delimiter I used
      > > g - all occurrences on the line
      > >
      > > I have a perl script that I wrote a while back that globs files in the
      > > current directory. I do not know if you have perl installed, but if you
      > > would like it I will send it to you (I will not send attachments to the
      > > list). The example usage is
      > >
      > > snr.pl OldPattern NewPattern File/s
      > >
      > If you have bash why not use it?
      > there are probably betterways of writting this but:
      >
      > subs="s/192\.168\.1\.1/192\.168\.1\.2/"
      > #or set to what ever values you like
      > pattern='*.c'
      > #or whatever group of files you like
      > #remove the pattern entirely to get ALL files
      >
      > for fn in $(ls $pattern)
      > do
      > #stream through sed, as other poster suggested
      > sed -e $subs $fn
      > done

      The perl option is also a good one. It also has the potential advantage
      of doing what you need "in-place" (i.e. without a temp file) like sed
      would require.

      --
      David Rock
      david@...
    • Show all 9 messages in this topic