Computing.Net > Forums > Unix > Assign Date to a Var

Assign Date to a Var

Reply to Message Icon

Original Message
Name: Nish
Date: September 30, 2002 at 00:26:04 Pacific
Subject: Assign Date to a Var
OS: Solaris 7
CPU/Ram: 256
Comment:

Dear All,
My OS : Solaris and Shell is ksh.
I have a requirement to assign date to a variable.
I tried following and failed.

myvar=date '+ %y%m%d_%h'

After that I need to do an awk fo all the files containing the same date and hour. (File name consists of date and hour)
eg. Myfile_NAME_020930_1325.0010
Therefore I need to awk all files that created this hour.
Appreciate your Help.


Report Offensive Message For Removal


Response Number 1
Name: David Perry
Date: September 30, 2002 at 03:56:40 Pacific
Reply: (edit)

find . -name "*myvar*" -exec ls -l {} \;


Report Offensive Follow Up For Removal

Response Number 2
Name: David Perry
Date: September 30, 2002 at 03:58:14 Pacific
Reply: (edit)

Sorry. That should have been

find . -name "*$myvar*" -exec ls -l {} \;


Report Offensive Follow Up For Removal

Response Number 3
Name: jimbo
Date: September 30, 2002 at 04:45:08 Pacific
Reply: (edit)

Here you go:

myvar=`date + %y%m%d_%h`

Use Backquotes

-jim


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Assign Date to a Var

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge