This question already has an answer here:
- bashrc lazy substitution 1 answer
I am trying to create an alias in .bashrc to time-stamp a directory. Obviously, it's not working out too well for me. For example:
alias testit="export testor=$(date +%d);mkdir ~/Desktop/$testor"
~> testit mkdir: cannot create directory ‘/home/SJL/Desktop/’: File exists
now if I run in command instead
~> export testor=$(date +%d) ~> mkdir ~/Desktop/$testor
directory created, no problem.
Now if I run instead:
~> export testor=$(date +%d);mkdir ~/Desktop/$testor
again, no problem.
going back to using the alias stated in .bashrc it does not work.
It's really curious because I've done similar things many many many times, but it seems that there's something going on/wrong with the date formatting.
I would really appreciate your input.