I have an alias file with the following line: alias ss="import /home/User/Pictures/screenshots/screenshot-$( date '+%Y-%m-%d-%H-%M-%S.png' )"

In terminal, when I type "ss" it runs the command and saves correctly. However, if I run it again, the date does not update. Am I missing something?


The problem is that the date command is executed at the time you define the alias (not at the time of the first call to the alias. You must quote the $:

alias ss="import /home/User/Pictures/screenshots/screenshot-\$( date '+%Y-%m-%d-%H-%M-%S.png' )"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.