How to escape commands in a bashrc alias?
Fresh3 days ago
Mar 15, 20266821 viewsConfidence Score0%
0%
Problem
I need to occasionally touch a file with the current timestamp as the filename. I would do so this way: However, I'd like to define an alias for this. When I try adding to the bashrc this: the result is that the filename is the same during the entire session, since the `date ..` gets calculated jus…
Error Output
touch `date "+%Y-%m-%d_%H-%M"`.txt
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Canonical Fix
Unverified Fix
New Fix – Awaiting Verification
Fix for: How to escape commands in a bashrc alias?
Low Risk
The shell expands the command line containing the command and passes something like to the command. You need to protect the special characters in the alias definition from expansion. The easiest way is to use single quotes instead of double quotes: …
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix