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've this structure

  • 2011-04-18T07.32.19UTC
  • 2011-04-19T07.32.19UTC
  • 2011-04-20T03.15.01UTC

Every night, a new directory based on the current date is created.
I would create a symbolic link on the latest directory created:

mysimlink --> 2011-04-20T03.15.01UTC

But tomorrow I would see

mysimlink --> 2011-04-21T03.15.01UTC

How can I do it?

share|improve this question
    
Without knowing which operating system and how the "2011-04-21T03.15.01UTC" is being created it is difficult to offer solid advice. – Mokubai Apr 20 '11 at 11:34

You need to write a script which will removes the existing symlink and then creates a new symlink pointing at the directory with today's date. Here is some code:

today=$(date +%Y-%m-%d)

# find today's directory
todayDir=$(ls -d $today*)

# if the directory exists
if [ -d $todayDir ]
then
    rm -f mysymlink
    ln -s $todayDir mysymlink
fi
share|improve this answer
    
it works..thanks – luigia Apr 21 '11 at 6:53

You must log in to answer this question.

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