I’m trying to write a bash script to create/check for the existence of a file based on the date. Basically I want to have a direcotry of todo_lists inside of which are files with todays todo list. So every time I open the terminal (mac os 10.6.8) it would check to see if 6-29-11.txt or whatever based on
date "+%m%d%Y"
if it exists just less the contents of it and if it doesn’t create one.
so I was wondering how to use that date formatted string as a file name and how to check string variables i.e.
[ -e date_string.txt ] && ...
How would I accomplish these things, I’m pretty new to bash
Try this:
The backticks (`) means, run this command and return the output as a string