Using Ubuntu 12.04. Using pipes (5 times): $ time echo XYZ | sed 's/X/A/g' | sed 's/Y/B/g' | sed 's/Z/C/g'ABCreal    0m0.005suser    0m0.000ssys 0m0.000s$ time echo XYZ | sed 's/X/A/g' | sed 's/Y/B/g' | sed 's/Z/C/g'ABCreal    0m0.004suser    0m0.000ssys 0m0.000s$ time echo XYZ | sed 's/X/A/g' | sed 's/Y/B/g' | sed 's/Z/C/g'ABCreal    0m0.004suser    0m0.004ssys 0m0.000s$ time echo XYZ | sed 's/X/A/g' | sed 's/Y/B/g' | sed 's/Z/C/g'ABCreal    0m0.005suser    0m0.000ssys 0m0.000s$ time echo XYZ | sed 's/X/A/g' | sed 's/Y/B/g' | sed 's/Z/C/g'ABCreal    0m0.005suser    0m0.004ssys 0m0.000snot using pipes (5 times): $ time echo XYZ | sed 's/X/A/g; s/Y/B/g; s/Z/C/g'ABCreal    0m0.003suser    0m0.000ssys 0m0.004s$ time echo XYZ | sed 's/X/A/g; s/Y/B/g; s/Z/C/g'ABCreal    0m0.003suser    0m0.000ssys 0m0.000s$ time echo XYZ | sed 's/X/A/g; s/Y/B/g; s/Z/C/g'ABCreal    0m0.003suser    0m0.000ssys 0m0.000s$ time echo XYZ | sed 's/X/A/g; s/Y/B/g; s/Z/C/g'ABCreal    0m0.003suser    0m0.004ssys 0m0.000s$ time echo XYZ | sed 's/X/A/g; s/Y/B/g; s/Z/C/g'ABCreal    0m0.003suser    0m0.000ssys 0m0.000s$ It's clear that NOT using pipes is faster. So it can be used to optimize a script: $ echo ABC | sed 's/A/X/g; s/X/Y/g'YBC$ My question: Merging the sed's always produce the same output? 
Are there any difference using pipes?
sed;perl
Yes, the two commands you posted are 100% equivalent, so you can safely change your script not to use pipes.But your reasoning is flawed: you only measured the time it takes to echo XYZ, not the actual sed invocations. You will however see that it's still faster not to use pipes :)dennis@spirit:~$ time sh -c 'echo XYZ | sed -e s/X/A/ | sed -e s/Y/B/ | sed -e s/Z/C/'ABCreal    0m0.009suser    0m0.000ssys 0m0.012sdennis@spirit:~$ time sh -c 'echo XYZ | sed -e s/X/A/ -e s/Y/B/ -e s/Z/C/'ABCreal    0m0.006suser    0m0.000ssys 0m0.006s