🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: ca.unix
Article #140

Re: passing date to variable

#140
From: The Hurdy Gurdy Man
Date: Sun, 14 May 2000 00:00
22 lines
1365 bytes
hummbabe@hotmail.com wrote:

> I'm trying to pass the current month and day to a variable for
> purposes of renaming and archiving files. here's the idea:
>
> #!/bin/sh
> v_date = date +%m%d
> mv file "file$v_date"

Did you try it this way?

#!/bin/sh
v_date=`date +%m%d`
mv file "file$v_date"

That seems like it should work.  The spacing on the assigning of the value
of the variable, as well as the backtick characters encasing the command
whose output will be assigned to the variable, are critical.  The quotes
around the file$v_date part don't need to be there, but it doesn't hurt to
have them there.

							Bryan
Technical Details
Message-ID: <I_mT4.59855$g4.1658619@newsread2.prod.itd.earthlink.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <391d7862.8563078@news.onemain.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10183f,3064a74fb26d2f96
X-Google-Attributes: gid10183f,public
From: The Hurdy Gurdy Man <bryan@tep12.ucsd.edu>
Subject: Re: passing date to variable
Date: 2000/05/14
Message-ID: <I_mT4.59855$g4.1658619@newsread2.prod.itd.earthlink.net>
X-Deja-AN: 623104708
References: <391d7862.8563078@news.onemain.com>
X-Complaints-To: abuse@earthlink.net
X-Trace: newsread2.prod.itd.earthlink.net 958266408 132.239.173.108 (Sat, 13 May 2000 18:06:48 PDT)
Organization: EarthLink Inc. -- http://www.EarthLink.net
User-Agent: tin/1.4.3-20000502 ("Marian") (UNIX) (FreeBSD/2.2.6-RELEASE (i386))
NNTP-Posting-Date: Sat, 13 May 2000 18:06:48 PDT
Newsgroups: ca.unix