1

How do I escape backticks as below:

root:~# 
root:~# cat .bash_aliases 
alias clean='docker rm `docker ps -aq`'
root:~# 

see also:

https://stackoverflow.com/q/1250079/4531180

and

https://stackoverflow.com/a/56674658/4531180

for possible alternate syntax of:

docker rm $(docker ps -a -q)

Nicholas Saunders
  • 1,054
  • 4
  • 16
  • 37
  • 2
    You have already quoted them using single quotes, why do you need to escape them further? – muru Sep 01 '20 at 08:00
  • perhaps I typed it in wrong, but there's supposed to be backticks around `docker ps -aq` which I couldn't get into the alias. – Nicholas Saunders Sep 01 '20 at 08:03
  • 2
    The output you show in the question look OK to me - ``alias clean='docker rm `docker ps -aq`'`` and it will function identically to what you have in the answer ``alias clean='docker rm $(docker ps -aq)'`` – muru Sep 01 '20 at 08:06

1 Answers1

0

yes, the work-around of:

root:~# 
root:~# alias clean
alias clean='docker rm $(docker ps -aq)'
root:~# 

works.

Nicholas Saunders
  • 1,054
  • 4
  • 16
  • 37