General Computing
linux command-line bash sed pipe
Updated Fri, 20 May 2022 15:27:59 GMT

Bash alias with Sed not working

Does anyone know why this alias isn't working?

alias tailsed="tailf error.log | sed -e 's/\\n/\n/g' -e 's/\\t/''/g'"

I've tried replacing the single quotes with doubles so that it's like:

alias tailsed='tailf error.log | sed -e "s/\\n/\n/g" -e "s/\\t/""/g"'

But the piped command still doesn't parse correctly like it does when it is run alone.


Functions remove all this quoting hell:

tailsed() { tailf error.log | sed -e 's/\\n/\n/g' -e 's/\\t//g'; }

Comments (2)

  • +0 – Ah, didn't know you could add functions inside the bash_aliases file. Works great, thanks! — Apr 11, 2014 at 08:25  
  • +0 – The bash startup scripts are just bash scripts, you can put anything there. — Apr 12, 2014 at 01:04