[PLUG] bash question
Marvin J. Kosmal
lamsokvr at xprt.net
Tue Aug 20 00:36:04 UTC 2002
On Monday 19 August 2002 12:41, you wrote:
> As soon as I hit <send> I knew I'd regret it:
>
> Marvin J. Kosmal wrote:
> :: On Monday 19 August 2002 11:39, you wrote:
> :: > :: On Monday 19 August 2002 10:46, you wrote:
> :: > :: > I'm writing a script where I want to figure out what
> :: > :: > month it will be X weeks from today. If it were one
> :: > :: > week from today, I could use date like this:
> :: > :: >
> :: > :: > date --date='+ 1 week' +%m
> :: > :: >
> :: > :: > This stores it to a variable (X):
> :: > :: >
> :: > :: > X=$(date --date='+ 1 week' +%m)
> :: > :: >
> :: > :: > But what if the 1 in the above statement is itself a
> :: > :: > variable?
> :: > :: >
> :: > :: > Y=1
> :: > :: > X=$(date --date='+ $Y week' +%m)
> :: > :: >
> :: > :: > I get this error:
> :: > :: >
> :: > :: > date: invalid date `+ $Y week'
> :: > :: >
> :: > :: > How do I proceed here?
> :: > ::
> :: > :: Try $(Y) week
> :: > ::
> :: > :: Marvin
> :: >
> :: > Marvin, did you? (Try it, I mean)?
> :: >
> :: > If it works I'd be mighty surpised since $(Y) will be just as
> :: > enclosed in quotes as $Y was. Which means it won't expand.
> :: >
> :: >
> :: > <Rant on> I'd sure like to see people take the extra 5
> :: > seconds to actually test their proposed solutions instead if
> :: > misleading people down dead-ends. Especially when the
> :: > proposed solution is trivially easy to test. It is extremely
> :: > frustrating to get 17 solutions (as I did on another list
> :: > with my recent xinerama problems) 16 of which were utterly
> :: > useless, misleading, "solutions" from people who didn't even
> :: > bother to read the problem statement fully. (Thanks to the
> :: > one or two who took the time to write a thoughtful answer.)
> :: > ...
>
> <snip>
>
> <Rant off>
>
> :: > Bad morning.
> :: >
> :: > Dean
> ::
> :: I agree!! ;-))
> ::
> :: Marvin
>
> What a nice response to a rather nasty reply! So nice, in fact,
> that my conscience prompts me to apologise for my rather testy
> e-mail message (though the drift of my comments still holds, in
> general).
>
> A gentle answer turns away wrath
> --- Proverbs 15:1
>
> Still a bad morning,
> Dean
It's a long life.
Worry about the important thing.
I have a friend who is dying....... ;-(
And he dosen't even know BASH!!!
Thanks for listening...
Marvin
More information about the PLUG
mailing list