Results 1 to 3 of 3

Thread: Substituting regexps in sh script?

  1. #1
    Junior Member
    Join Date
    Jul 2002

    Substituting regexps in sh script?

    What shell command can I use to substitute regular expressions? Something like the Perl s/// command.
    It's intended to be used in a makefile.

  2. #2

    Re:Substituting regexps in sh script?

    sed (the stream editor) will do that. Syntax goes something like this:
    sed 's///' <input file>
    Left alone like this, the output will go to stdout, so you will need to redirect it as necessary. Also, as you might expect, the input can be piped from another command instead of using an input file.
    Just don't expect all the features that you get with perl! There is a PET on regexps (written by some dodgy ne'erdowell) that gives examples as to what regexps can be used with sed. The PET doesn't mention pattern match variables (remembering stuff matched in parethesis) which you may be used to - these can also be used with sed.

  3. #3
    Junior Member
    Join Date
    Jul 2002

    Re:Substituting regexps in sh script?

    Thanks, that's exactly what I needed

Similar Threads

  1. script
    By try in forum Linux - General Topics
    Replies: 0
    Last Post: 12-15-2008, 07:43 AM
  2. Want a Deleting Script
    By bikram in forum Programming
    Replies: 2
    Last Post: 11-12-2007, 07:48 PM
  3. Java Script Help.
    By G-Unit in forum Windows - General Topics
    Replies: 2
    Last Post: 03-07-2005, 12:13 AM
  4. Probs in a script called from another script
    By Outlaw in forum Programming
    Replies: 1
    Last Post: 03-12-2004, 02:54 PM
  5. My first Ruby script!
    By vee-eye in forum Programming
    Replies: 11
    Last Post: 01-14-2002, 09:49 AM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts