Alex Asked: 2009-06-16 01:39:22 +0800 CST2009-06-16 01:39:22 +0800 CST 2009-06-16 01:39:22 +0800 CST Bash command for regular expression substitution 772 What bash command can be used for regex substitution on a pipe? cat foo.txt | someprogram linux ubuntu bash regex pipe 3 Answers Voted Best Answer nik 2009-06-16T01:43:49+08:002009-06-16T01:43:49+08:00 You probably want sed 's/exp1/exp2/g' foo.txt > foo2.txt Read more at Sed tutorial, Another tutorial, and A small tutorial at Linux HOWTOs Kyle Brandt 2009-06-16T03:40:21+08:002009-06-16T03:40:21+08:00 You can also use perl one liners if you find you want more regular expression features than sed provides. See this link for a comparison. nik's example would look like: perl -ple 's/exp1/exp2/g' foo > foo2.txt David Pashley 2009-06-16T01:40:02+08:002009-06-16T01:40:02+08:00 The program you are looking for is sed.
You probably want
Read more at Sed tutorial, Another tutorial, and A small tutorial at Linux HOWTOs
You can also use perl one liners if you find you want more regular expression features than sed provides. See this link for a comparison. nik's example would look like:
The program you are looking for is sed.