I have this command in a bash script:
sudo java -jar ./myjar.jar name_%1$tY%1$tm.csv ./sql/blablab.sql someArgument
or
sudo java -jar ./myjar.jar "name_%1$tY%1$tm.csv" ./sql/blablab.sql someArgument
Any of these two commands will yield these 3 arguments:
Arguments : name_%1%1.csv ./sql/blablab.sql someArgument
As you can see, % and/or $ did not get escaped. I’m looking for a way to escape them.
Best regards
In bash a non-quoted backslash
\is the escape character. It preserves the literal value of the next character that follows, with the exception of\n. You don’t need to escape the%character but you do have to escape the$or bash will consider it a variable and expand it.In your case,
should work.