I am using Python with the command-line option -c. Printing some strings works:
python -c "print('foo')" foo but printing an exclamation mark triggers some bash-related error:
python -c "print('!')" -bash: !': event not found Can anyone explain what I am doing wrong? I cannot understand why python/bash could not parse this very simple example.
", it is first expanded by your shell. With single quotes', the shell will take the argument as literal string:python -c 'print("!")'(using double quotes inside python to avoid quoting quotes)