Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
Substituting regexps in sh script?
Results 1 to 3 of 3

Thread: Substituting regexps in sh script?

  1. #1
    Junior Member
    Join Date
    Jul 2002
    Posts
    54

    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:
    Code:
    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
    Posts
    54

    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

Bookmarks

Posting Permissions

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