regex - Find and replace multiple pairs of chars -
i have text file , use sed
editor regex find , replace characters in it. say, a->b, g->h, r->d , e->q.
like this:
sed -i "s/a/b/g" file.html >nul sed -i "s/g/h/g" file.html >nul sed -i "s/r/d/g" file.html >nul sed -i "s/e/q/g" file.html >nul
all works fine. want combine single regex line. can i? after googling , reading lot refex, see no way right now. thanks!
tr command this: tr < file.html 'agre' 'bhdq'
but if you're asking how make commands run go:
sed -e "s/a/b/g" -e "s/g/h/g" -e "s/r/d/g" -e "s/e/q/g" file.html
or more if commands different:
sed -e "s/a/b/g" file.html | sed -e "s/g/h/g" | sed -e "s/r/d/g" | sed -e "s/e/q/g"
Comments
Post a Comment