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?

New contributor
soundsofpolaris is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

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

soundsofpolaris is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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