Filenames based on the date
How do I create a filename based on the date?
i.e. I'd like to run 'date' from the prompt, and create a file based upon that. for example, create a file with the prefix 'test-' which would create a file with a name like: test-Fri Nov 18 16:38:50 GMT 2005.txt Thanks. |
Code:
$ touch "test-`date`.txt" |
Cheers!
|
You might want something like this for easier sorting:
Code:
touch "test-`date +%Y%m%d`" |
Re: Filenames based on the date
Quote:
|
How about:
Code:
touch $( echo "test-$( date )" | sed 's/ //g' ) Or better still: Code:
touch $( echo "test-$( date )" | sed -e 's/ //g' -e 's/\://g' ) edit: blindcoder's is good too. Nice and short. |
All times are GMT -5. The time now is 04:53 AM. |