Unix Date Processing
List files based on dates I like to list the files only today's or a particular days files in a directory. You should be able to do a ls -l and then pipe it to a grep for the date you want. And a chronological listing is quite helpful:
Print files with certain dates How can I print a file with a date timestamp to a file? ls -al |grep "Oct 18 200X" >filename.txt
ls -al *.txt|grep "Oct 18 200X" >filename.txt This would put only those files with that date and that
file extention in there.
Change date format using shell I am trying to change the date format from MM/DD/YYYY to MMDDYYYY in the fixed width file using shell. Dates are in fields 19-28 and 29-38. I guess you want to format the date in your required format
using the shell script.
Date-renaming files I'm trying to write a simple backup script using rsync, tar and crontab .. but I want to be able to rename a newly created archive with the current date. I sometimes use dates in file naming, but I prefer sequential
numbering since that is unique, and I still have the date stamp of the
file to show me when it was created. When using dates, consider including
hour and min, and maybe even sec. Following example uses only ymd. The
nested command in back apostrophes is replaced by its output:
If the utility does not let you name the output, but instead always outputs to some default file name, you can rename it after creation: outfile=backup_`date +%Y%m%d`
See Also
Have a Unix Problem
Unix Books :-
Return to : - Unix System Administration Hints and Tips (c) www.gotothings.com All material on this site is Copyright.
|