1
I want to create an alias:
alias readFile='ls file1.todaysdate' where todaysdate is in format 130714.
How would i do this?
1
I want to create an alias:
alias readFile='ls file1.todaysdate' where todaysdate is in format 130714.
How would i do this?
3
you can use the date command to give you the date in that format:
date +%y%m%d
this gives you the YYMMDD format. In the alias file you can drop that date format into your command with the `` back-ticks like so:
alias readFile='ls file1.`date +%y%m%d`'
everything between the back-ticks is executed and the output is placed instead of the back-ticks. so
echo "hello `whoami`"
would say "hello " followed by your username.
Another form of the command substitution (backtics) is
$(command)
. The latter variant is better suitable for nesting. – mpy – 2013-07-16T18:53:25.227i tried $(command) and that works as well – 4reel77 – 2013-07-16T19:24:13.833