I use Bash
I wrote a command for printing only docker id separate with whitespaces on one line.
docker ps -a | grep -E '^[a-z0-9]{12}' -o | awk '{printf "%s ",$0} END {print ""}'
Works well, so I decided to make it an alias.
First, it seems that the whitespace here "%s "
was a problem, so I decided to escape it
The new command looks like this:
docker ps -a | grep -E '^[a-z0-9]{12}' -o | awk '{printf "%s\ ",$0} END {print""}'
Now, no errors when sourcing the .bashrc but when I tried to run my alias I get the following error:
{printf %s ,-bash} END {print}
^ syntax error
I already looked at this fish: whitespace in alias but I am not using fish
EDIT, my alias looks like this:
alias dockerid="docker ps -a | grep -E '^[a-z0-9]{12}' -o | awk '{printf "%s\ ",$0} END {print""}'"
Note that if I use single quote, the source command fails
"
, but then it contain other"
(e.g. in awk command) which in reality are used as end of previous"
. You should escape all inner"
, e.g. with\"