bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Formating variable with caracter and date.


From: Dave B
Subject: Re: Formating variable with caracter and date.
Date: Fri, 12 Dec 2008 12:18:44 +0100
User-agent: Thunderbird 2.0.0.18 (X11/20081124)

Dolphin06 wrote:

> Hello all,
> 
> I would like to give a variable a value which have a format like this one:
> <3 letters>-<date>-<digit>
> <date> should be yymmdd.  Date of the day by default.
> How would i do this, i know the date command is date +"%y-%m-%d", but i dont
> know the syntax for mixing letters date and digit into one variable.
> Also i would like to give the user a chance to change this default value, by
> letting him enter one, so i would like to know how can i check if the
> entered value is in the correct format.

First of all, this list if for reporting bash bugs, not for general help
requests. For that purpose, there are other, more appropriate, places, like
for example the Internet newsgroup comp.unix.shell.

Then, regarding your request:

To assign that string to the variable, assuming <3 letters> is "ABC", and
<digit> is "5" (replace with your own values), you can do this:

var=ABC-$(date +%y%m%d)-5

The part about checking depends on what you want to check exactly, which
isn't clear from your description.

-- 
D.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]