//View Tip #310
Similar Tips
» SSH Auto Complete
» Manipulate Bash sockets using /dev/tcp
» Simple password generator
» Change extension on a group of files using only bash builtins an
» another solution to #67


Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
Seen on http://www.splitbrain.org/blog/2008-02/27-keeping_your_home_directory_organized

Having one temporary directory for downloads etc can quickly become a mess, so try this tip to organise by date. Put this into your .bashrc

export TD="$HOME/temp/`date +'%Y-%m-%d'`"
if [ ! -z "$1" ]; then
td="$HOME/temp/`date -d "$1 days" +'%Y-%m-%d'`";
mkdir -p $td; cd $td
unset td

You'll receive a new function 'td' for making temp-dirs under $HOME/temp/ named by date. It is also possible to switch days back with 'td -[n]', i. e. 'td -3' which means '3 days back from now'.

View Comments »


Add your comment

Comments are currently disabled
The only problem I see with this little tidbit is that if you are working around midnight.  If you use td before midnight, and are still logged in after midnight, then $TD is still set to yesterday.

Move the TD=.... to inside the function to fix that.
Posted 2009-04-15 12:28:17

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit