hello mark,
On 08/19/2013 01:56 PM, Mark Haney wrote:
I've hit a problem I can't quite figure out which a bash
script I'm
writing. I'm trying to copy backup files in the format
2013-August-18--1123.zip to an NFS share. I want to have the script copy
the file with just the date. In bash I've setup vars that get the current
date:
# Date variables
log_year=`date "+%Y"`
log_month=`date "+%B"`
log_day=`date "+%d"`
# Filename format YYYY_MM_DD--HHMM.zip
filename=$log_year"-"$log_month"-"$log_day"--"/*".zip"
why are you showing "/*" in your "filename=" statement?
such would indicate date as a directory and _all_ files in a directory that
ends with "zip".
if you meant to _delimit_ the "*", then "\" is used to delimit.
i believe actual 'filename' should be;
$log_year"-"$log_month"-"$log_day"*.zip"
The problem is I don't really care about the stuff after the
'--'.
you better care about it as it is written, as, for what you want, 'filename'
would be as i present.
I.e. from the CLI I'd just 'ls 2013-August-18--*.zip' to
get all the
files with that date in the file name. How can I do that in a bash script?
not if you use the "/*".
problem just might be that you have worked with it too long and not
really seeing what you are doing. ;=)
ls 2013-August-18--*.zip
should show _all_ files for 18 august, 2013, regardless of time, in
'current' directory.
if not, something is bad wrong.
when i time stamp a backup file, i use;
yyyy-mmdd-hhmm-filename
or
filename-yyyy-mmdd-hhmm
then, when i collect them for transfer to backup tape media, i use;
find . yyyy-mmdd-* | sort | cpio -o -[arguments] /dev/tape
or
find . *-yyyy-mmdd | sort | cpio -o -[arguments] /dev/tape
which finds _all_ files of *-yyyymmdd or yyyymmdd-* and they are backed up.
[and yes, i use *yyyymmdd* for various reasons]
not that much difference if you are using multi "-".
from 1 of my script files;
find $1 -depth | sort | cpio -o -Bcmv > [path to backup file]$2.cpio
and then backup the *.cpio file.
"$1" and "$2" are passed to script from command line.
i have a rather extensive collection of script files that i use for tape
backup that i have used for years for both argument passing and no argument
passing for regularly preformed backups with out problems.
i can not access the extensive list of "find|sort|cpio" at this time.
see attached for a short list. it should give you an idea of using find,
sort, and cpio.
hth.
--
peace out.
in a world with out fences, who needs gates.
sl6.3 linux
tc.hago.
g
.