gres
global regular expression substitute
Many thanks to grep for the inspiration.
A simple shellscript to replace patterns in textfiles. It is not groundbreaking or anything, but it sped things up for me in the *nix world.
(note: this just makes a sed command a little more usefull, and as such, only writes to standard output.
Remember to redirect output.)
#!/usr/bin/sh
#GlobalRegularExpressionSubstitute
#check  arguments

if [ $# -ne 3 ]
  then
        echo "BZZZT!  Usage: old-pattern new-pattern filename. 
        Dont forget: sed wont redirect output unless you tell it to"
        exit 1
fi

if [ -f $3 ]
  then
        file_name=$3
  else
        echo " file \"$3\" does not exist, please try again."
        exit 2
fi
#do the work

sed -e "s/$1/$2/" $file_name

exit 0

Gres (?), n.

Grass.

[Obs.]

Chaucer.

 

© Webster 1913.

Log in or register to write something here or to contact authors.