[Wylug-discuss] Copy files by date
Smylers
Smylers at stripey.com
Wed Feb 1 13:50:51 UTC 2012
linux at sh2515.plus.com writes:
> > However ... I still think that for what you're doing you'd be much
> > better off using rsync than trying to devise your own copying
> > routine.
>
> for a temporary solution the IT people will not allow any installation
> of other software.
Ah, I was considering rsync to be so standard that it would be installed
already on all Unix-like systems.
I take it OS X doesn't have it as standard then?
> > if [[ "$FILE" == *AA*.txt ]]
> >
> > Though note that that pattern will match things like these, which
> > you might've meant to categorize under ZZ rather than AA:
> >
> > ZZ_AARDVARK.txt
> > AAAARGH/ZZ.txt
>
> Noted, each file has a unique reference number, AA, BA etc is the first 2
> letters before the reference number linking it to a section.
So a pattern of "${FILE##*/}" == AA*.txt would be safer, ensuring that
the AA doesn't match in the directory name or somewhere other than at
the start of the filename.
> would I put something like:
>
> if
> else
> if
> else
> if
> else
> if
> else
> fi
> fi
> fi
> fi
>
> Can't find multiples of if else if on the web
You don't need to go to the web; Bash comes with built-in help. Simply
do:
$ help if
and you'll see there's an optional elif clause you can use.
> to check if fi is needed at the end of every else.
The way you've written it above each else statement is a new nested if
statement, so they do all need a separate fi. Whereas using elif just
chains another option on to the existing if statement, without any
nesting.
> I am absolutely astounded by the information and help you have given,
> I am truly grateful for this.
Well I've learnt things too: I learnt about -daystart from you, and some
date options from Aaron and Wills, and various things about Macs from
several people, including guidance for installing Gnu tools.
> I just hope you are not charging me by the word. Hope I can return the
> help one day.
And I'm only offering what others kindly offered to me. Mostly I'm not
'returning' help to the same people, but if we all simply pass on what
we know to others that should work out OK.
Cheers
Smylers
--
http://twitter.com/Smylers2
More information about the Wylug-discuss
mailing list