Re: [SLUG] bash script problem - Thanks for the 3 nice responses.

From: Ron Youvan (ka4inm@tampabay.rr.com)
Date: Wed Oct 05 2005 - 20:22:12 EDT


   Thanks for the 3 nice responses, I will try all, I will learn.
I never heard of the: "backtick operator" so that may be MY problem.

>>man date says: "date - print or set the system date and time"
>>It prints the system time, but getting it into a variable
>>seems to be my problem.
>> I have tried everything that I can think of including:
>>touch < date (+formatting info)

>> Can anyone please point me in the proper direction?

> #!/bin/sh
> datefield=`date +%Y%M%d`
> filename=FOO.${datefield}
> touch $filename

> You want to use $() or backticks `` around your date command:

> $ touch $(date +%Y-%m-%d.log)
> or
> $ touch `date +%Y-%m-%d.log`

> To set a variable, just use the same technique:

> LOGDATE=`date +%Y-%m-%d.log`

> date_args=%G_%m_%d
> linkname=/tmp/write_here
> filename="/tmp/`date +$date_args`"
> touch "$filename"
> ln -sf "$filename" "$linkname"

> or if you don't like all the fancy stuff,

> touch "/tmp/`date +%G_%m_%d`"

> and have no link.

> Backquotes aka $(...) are your friends.

-- 
    Ron
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS).  Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 17:57:52 EDT