I have a pretty standard directory higherachy, year, month, date, for log files. If I want to go to todays logs I have to type cd logs/2015/12/16/

By itself this wouldn't be bad, but since I actually have dozens of different logs and jump between them often it gets tedious. I want to write a quick alias or script to allow me to quickly jump to today's directory.

I could do this with awk or sed and string manipulation, but I feel like this is over complicating it. is there a simpler tool for doing this then trying to parse and interpret the directories themselves?

Ultimately my final alias/script would likely allow me to do something like "goLog foo" to go to the latest directory of the foo subdirectory of logs, with "goLog bar" doing the same with the bar subdirectory etc.

3 Answers 3


Quickest solution I can think of:

alias goLog="cd log/$(date +%Y/%m/%d)"

Alternatively, a function:

ctd() { cd logs/$(date +%Y/%m/%d) }

Quickest solution I can think of:

alias goLog="cd log/$(date +\"%Y\")/$(date +\"%m\")/$(date +\"%d\")"

This function should work for you

ctd(){ cd logs/$(date +"%Y")/$(date +"%m")/$(date +"%d") }

Of course you may need to adjust the path

You must log in to answer this question.

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