linuxshellarguments

How can I pass an argument with an exclamation mark on Linux?


I have a simple Python script that receives a username and password as arguments, but my password contains two exclamation marks. When I call my script like

cd ~/Desktop
emailsender.py -u username -p password!!

A command that I entered earlier replaces the exclamation marks:

emailsender.py -u username -p "passemailsender.py -u username -p passwget wget http://www.crobot.com.hr/templog"

I can escape exclamation marks with backslash (\), but my password changes.

Is there solution for this, how can I escape exclamation marks without changing my password?


Solution

  • You should be able to simply wrap things in single quotes in the shell.

    emailsender.py -u username -p 'password!!'