On Wed, Mar 23, 2011 at 6:39 PM, Binand Sethumadhavan binand@gmail.comwrote:
2011/3/23 Rony Bill gnulinuxist@gmail.com:
I am creating / appending files using a variable as the input name. Eg. $USER.jpeg makes a file called rony.jpeg . I want to add 2 variables to
the
file name instead of one and make $USER-$DATE.jpeg (rony-23/03/11.jpeg). What is the correct syntax for it as I keep getting errors in the mv as
well
as rename command. Tried $USER_$DATE or $USER.$DATE etc but no result.
Did
look up google but it has complex sed scripts.
Your $DATE appears to be misformatted - Linux (or for that matter, any Unix) cannot have filenames that contain the '/'. It is one of the two characters that are forbidden in filenames.
Apart from that, $USER-$DATE and $USER.$DATE both should work ($USER_$DATE will not). Please post actual script and its output for better debugging.
Yes you are right. The '/' in the date format was the trouble maker. Thanks for the tip. I have changed the date format to 'date +%d-%m-%Y' and $USER-$DATE.jpeg works beautifully.
The attendance register that I am making will give a welcome message on the console and ask for the name. When the employee punches in his/her name, the common script will calculate how late/early the person is with the reference time. It will also click a photo of the person and make a tiny image saved with that user's name and the current date. The time difference will be recorded in the csv file created with the same user's name. At the beginning of the month or end, a separate cron script will move all the user.csv files to another location. This ensures each csv file has a monthly data only. The original script will re-create the new csv files and append them daily.