Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to create an alias:

alias readFile='ls file1.todaysdate' where todaysdate is in format 130714.

How would i do this?

share|improve this question
up vote 3 down vote accepted

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.

share|improve this answer
    
Another form of the command substitution (backtics) is $(command). The latter variant is better suitable for nesting. – mpy Jul 16 '13 at 18:53
    
perfect! thanks – 4reel77 Jul 16 '13 at 18:58
    
i tried $(command) and that works as well – 4reel77 Jul 16 '13 at 19:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .