Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.advocacy > #465530

Re: The substantiation that -highhorse asked for

From owl <owl@rooftop.invalid>
Newsgroups comp.os.linux.advocacy
Subject Re: The substantiation that -highhorse asked for
Date 2018-09-01 23:59 +0000
Organization O.W.L.
Message-ID <g9a799aaefa.o3x12@rooftop.invalid> (permalink)
References (10 earlier) <pOCiD.19384$Vl2.16436@fx46.iad> <9a0ab3.ga3or@rooftop.invalid> <%kEiD.5132$mJ1.2741@fx24.iad> <szbpbi3oua.gy@rooftop.invalid> <PYEiD.9367$SG2.8756@fx29.iad>

Show all headers | View raw


DFS <nospam@nospam.com> wrote:
> On 9/1/2018 6:40 PM, owl wrote:
>> DFS <nospam@nospam.com> wrote:
>>> On 9/1/2018 6:00 PM, owl wrote:
>>>> DFS <nospam@nospam.com> wrote:
>>>>> On 9/1/2018 12:28 PM, owl wrote:
>>>>>
>>>>> I didn't show an entry I have - "Archive" - in which I call a function
>>>>> that goes to the db to find the earliest post in a group.
>>>>>
>>>>>   From the Windows and Linux command line it's:
>>>>> $ sqlite3 dbfile "select min(date) from table where group = 'cola';"
>>>>>
>>>>> In bash is it just:
>>>>>
>>>>> beginArchDate {
>>>>>     sqlite3 db "select min(date) from table where group = $1;"
>>>>> }
>>>>>
>>>>> starts["Archive"]=$(beginArchDate $1 ${datefmt})
>>>>>
>>>>> anon@lowtide:~/code/ifs$ ./startdate Archive cola
>>>>>
>>>>
>>>> That doesn't look like it's going to work.
>>>
>>>
>>> It was supposed to be a question.
>>>
>>> "In bash is it just:"
>> 
>> If you're going to call it like this
>> 
>>     ./startdate Archive cola
>> 
>> Try something like this:
>> 
>> beginArchDate () {
>>     sqlite3 db "select min(date) from table where group = $1;"
>> }
>> 
>> #...
>> 
>> starts["Archive"]=$(date -d "$(beginArchDate ${2})" ${datefmt})
> 
> 
> This special case 'Archive' isn't subtracted from the current date to 
> get the startdate.  So is it:
> 
> starts["Archive"]=$("$(beginArchDate ${2})" ${datefmt})
> 

No, assuming your beginArchDate function returns a typical date
string, you want to pass that string to "date -d" along with the
format specifier ${datefmt}.

       -d, --date=STRING
              display time described by STRING, not 'now'

The $(...) expects a command.  The outer $(...) in
    $("$(beginArchDate ${2})" ${datefmt})
would just contain the date string returned by beginArchDate ${2}
followed by the expanded ${datefmt}, and would throw a "command not
found."

anon@lowtide:~/code/ifs$ cat -n dated
     1  #!/bin/bash
     2
     3  declare -A starts
     4
     5  if [ ${#} -ne 2 ];then
     6    echo "feed me a date period and a news group"
     7    exit
     8  fi
     9
    10  beginArchDate() {
    11    echo "Mar 1 1999"
    12  }
    13
    14  datefmt="+%d-%b-%Y"
    15
    16  starts["Archive"]=$(date -d "$(beginArchDate ${2})" ${datefmt})
    17  starts["Darkive"]=$("$(beginArchDate ${2})" ${datefmt})
    18
    19  echo starts[\"${1}\"]: ${starts["${1}"]}
    20
anon@lowtide:~/code/ifs$ 

anon@lowtide:~/code/ifs$ ./dated Darkive cola
./dated: line 17: Mar 1 1999: command not found
starts["Darkive"]:
anon@lowtide:~/code/ifs$ ./dated Archive cola
./dated: line 17: Mar 1 1999: command not found
starts["Archive"]: 01-Mar-1999
anon@lowtide:~/code/ifs$ 

Back to comp.os.linux.advocacy | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-28 08:28 -0400
  Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-28 09:20 -0700
    Re: The substantiation that -highhorse asked for fr314159@gmail.com - 2018-08-28 11:27 -0700
      Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-28 11:39 -0700
      Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-29 09:46 -0400
    Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-28 14:52 -0400
      Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-28 12:20 -0700
  Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-28 17:21 +0000
    Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-28 14:46 -0400
      Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-28 19:14 +0000
        Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-28 12:30 -0700
          Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-28 20:09 +0000
            Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-28 13:58 -0700
              Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-28 21:16 +0000
                Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-28 14:31 -0700
                Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-28 21:43 +0000
                Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-28 15:06 -0700
                Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-28 22:26 +0000
                Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-28 15:35 -0700
                Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-28 23:14 +0000
                Re: The substantiation that -highhorse asked for Snit <usenet@gallopinginsanity.com> - 2018-08-28 14:57 -0700
            Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-28 23:11 -0400
              Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-29 06:14 +0000
                Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-29 09:34 -0400
                Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-29 14:31 +0000
                Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-29 11:01 -0700
                Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-31 12:33 +0000
                Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-31 09:16 -0700
                Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-31 16:53 +0000
                Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-31 10:22 -0700
                Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-31 17:53 +0000
                Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-31 11:36 -0700
                Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-09-01 13:45 +0000
                Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-09-01 13:59 +0000
                Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-09-01 08:15 -0700
                Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-09-01 16:00 +0000
                Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-09-01 11:20 -0700
                Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-31 15:00 -0400
                Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-31 19:40 +0000
                Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-09-01 10:15 -0400
                Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-09-01 08:22 -0700
                Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-09-01 16:28 +0000
                Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-09-01 16:39 -0400
                Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-09-01 22:00 +0000
                Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-09-01 18:27 -0400
                Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-09-01 22:40 +0000
                Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-09-01 19:09 -0400
                Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-09-01 23:59 +0000
        Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-28 23:01 -0400
          Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-29 06:26 +0000
  Re: The substantiation that -highhorse asked for "F. Russell" <fr@random.info> - 2018-08-28 19:25 +0000
    Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-29 09:32 -0400
      Re: The substantiation that -highhorse asked for fr314159@gmail.com - 2018-08-29 06:46 -0700
        Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-29 09:55 -0400
          Re: The substantiation that -highhorse asked for fr314159@gmail.com - 2018-08-29 08:02 -0700
            Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-09-01 10:14 -0400
          Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-29 15:12 +0000

csiph-web