3

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.

  • a)you should use single quotes around the sed, as in your first example, and as for the double quote, what if you do \"? b)it's kind of cheating and too easy to be interesting but you could do something like \d22 – barlop Apr 10 '14 at 16:47
4

Functions remove all this quoting hell:

tailsed() { tailf error.log | sed -e 's/\\n/\n/g' -e 's/\\t//g'; }
  • Ah, didn't know you could add functions inside the bash_aliases file. Works great, thanks! – Ken Apr 11 '14 at 8:25
  • The bash startup scripts are just bash scripts, you can put anything there. – glenn jackman Apr 12 '14 at 1:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.