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


Groups > alt.os.linux.slackware > #26511 > unrolled thread

Re: bash script problem ?

Started byno.top.post@gmail.com
First post2016-03-16 16:53 +0000
Last post2016-03-16 17:43 +0000
Articles 6 — 6 participants

Back to article view | Back to alt.os.linux.slackware


Contents

  Re: bash script problem ? no.top.post@gmail.com - 2016-03-16 16:53 +0000
    Re: bash script problem ? William Unruh <unruh@invalid.ca> - 2016-03-16 17:08 +0000
      Re: bash script problem ? Unknown <dog@gmail.com> - 2016-03-17 11:00 +0000
        Re: bash script problem ? Joe Beanfish <joebeanfish@nospam.duh> - 2016-03-17 14:07 +0000
    Re: bash script problem ? "Helmut Hullen" <Helmut@Hullen.de> - 2016-03-16 18:14 +0100
    Re: bash script problem ? Rich <rich@example.invalid> - 2016-03-16 17:43 +0000

#26511 — Re: bash script problem ?

Fromno.top.post@gmail.com
Date2016-03-16 16:53 +0000
SubjectRe: bash script problem ?
Message-ID<ncc31c$gle$1@dont-email.me>
In article <>, Teemu Likonen <tlikonen@iki.fi> wrote: 

> 
> rich@example.invalid [2016-03-10 15:22:57Z] wrote:
> 
> > Step 1, don't use the legacy sh backtick substitution syntax for this
> > (because it cannot nest).  Use Bash's $() substitution instead (because
> > it can nest).
> 
> I agree that $() is better but ``'s can nest:=20
> 
>     $ echo Year: `date \`echo +%Y\``
>     Year: 2016
> 
That's spooky ! Who <associated> +%Y with "2016" ?
Lets have some examples of nesting, without extra spooky-stuf.

[toc] | [next] | [standalone]


#26512

FromWilliam Unruh <unruh@invalid.ca>
Date2016-03-16 17:08 +0000
Message-ID<ncc3v8$iug$1@dont-email.me>
In reply to#26511
On 2016-03-16, no.top.post@gmail.com <no.top.post@gmail.com> wrote:
> In article <>, Teemu Likonen <tlikonen@iki.fi> wrote: 
>
>> 
>> rich@example.invalid [2016-03-10 15:22:57Z] wrote:
>> 
>> > Step 1, don't use the legacy sh backtick substitution syntax for this
>> > (because it cannot nest).  Use Bash's $() substitution instead (because
>> > it can nest).
>> 
>> I agree that $() is better but ``'s can nest:=20
>> 
>>     $ echo Year: `date \`echo +%Y\``
>>     Year: 2016
>> 
> That's spooky ! Who <associated> +%Y with "2016" ?

The command "date" did. This says to run the date command with the
argument being the output of the echo command. In this case the latter
as +%Y so this is running
date +%Y 
which is the year in which the date command was run. The ouput is then
the argument to the outter echo command. 


> Lets have some examples of nesting, without extra spooky-stuf.

extra spooky-stuf? 
man date

>
>

[toc] | [prev] | [next] | [standalone]


#26517

FromUnknown <dog@gmail.com>
Date2016-03-17 11:00 +0000
Message-ID<pan.2016.03.17.21.04.33@gmail.com>
In reply to#26512
On Wed, 16 Mar 2016 17:08:56 +0000, William Unruh wrote:

> On 2016-03-16, no.top.post@gmail.com <no.top.post@gmail.com> wrote:
>> In article <>, Teemu Likonen <tlikonen@iki.fi> wrote:
>>
>>
>>> rich@example.invalid [2016-03-10 15:22:57Z] wrote:
>>> 
>>> > Step 1, don't use the legacy sh backtick substitution syntax for
>>> > this (because it cannot nest).  Use Bash's $() substitution instead
>>> > (because it can nest).
>>> 
>>> I agree that $() is better but ``'s can nest:=20
>>> 
>>>     $ echo Year: `date \`echo +%Y\``
>>>     Year: 2016
>>> 
>> That's spooky ! Who <associated> +%Y with "2016" ?
> 
> The command "date" did. This says to run the date command with the
> argument being the output of the echo command. In this case the latter
> as +%Y so this is running
> date +%Y
> which is the year in which the date command was run. The ouput is then
> the argument to the outter echo command.
> 
> 
>> Lets have some examples of nesting, without extra spooky-stuf.
> 
> extra spooky-stuf?
> man date
> 
> 
date `echo +%Y` == 2016
echo  `date \`echo +%M\`` == 33
echo  `date \`echo +%D\`` == 03/17/16
date `echo +%M` == 35
date `echo +%D` == 03/17/16

There's nesting: lisp; & there's concatenation/piping;
but this is a load of ad-hoc crap!


BTW `wily` is great for this.
No need to touch the kybrd.

[toc] | [prev] | [next] | [standalone]


#26518

FromJoe Beanfish <joebeanfish@nospam.duh>
Date2016-03-17 14:07 +0000
Message-ID<ncedmh$sqc$1@dont-email.me>
In reply to#26517
On Thu, 17 Mar 2016 11:00:14 +0000, Unknown wrote:

> On Wed, 16 Mar 2016 17:08:56 +0000, William Unruh wrote:
> 
>> On 2016-03-16, no.top.post@gmail.com <no.top.post@gmail.com> wrote:
>>> In article <>, Teemu Likonen <tlikonen@iki.fi> wrote:
>>>
>>>
>>>> rich@example.invalid [2016-03-10 15:22:57Z] wrote:
>>>> 
>>>> > Step 1, don't use the legacy sh backtick substitution syntax for
>>>> > this (because it cannot nest).  Use Bash's $() substitution instead
>>>> > (because it can nest).
>>>> 
>>>> I agree that $() is better but ``'s can nest:=20
>>>> 
>>>>     $ echo Year: `date \`echo +%Y\``
>>>>     Year: 2016
>>>> 
>>> That's spooky ! Who <associated> +%Y with "2016" ?
>> 
>> The command "date" did. This says to run the date command with the
>> argument being the output of the echo command. In this case the latter
>> as +%Y so this is running date +%Y which is the year in which the date
>> command was run. The ouput is then the argument to the outter echo
>> command.
>> 
>> 
>>> Lets have some examples of nesting, without extra spooky-stuf.
>> 
>> extra spooky-stuf?
>> man date
>> 
>> 
> date `echo +%Y` == 2016
> echo  `date \`echo +%M\`` == 33
> echo  `date \`echo +%D\`` == 03/17/16
> date `echo +%M` == 35
> date `echo +%D` == 03/17/16
> 
> There's nesting: lisp; & there's concatenation/piping;
> but this is a load of ad-hoc crap!
> 
> 
> BTW `wily` is great for this.
> No need to touch the kybrd.

<soapbox>
Not crap, beauty. The command line lets you form things the original
author didn't conceive of. Unlike most GUIs which only allow the small
set of things the author thought to allow you to do.

Sure the above examples are contrived and one would normally just
   date +%Y
But in a more complex situation as your original script the ad-hoc
ability of the command line is very useful and powerful.
</soapbox>

[toc] | [prev] | [next] | [standalone]


#26513

From"Helmut Hullen" <Helmut@Hullen.de>
Date2016-03-16 18:14 +0100
Message-ID<D$zlppVy1uB@helmut.hullen.de>
In reply to#26511
Hallo, no.top.post,

no.top.post@gmail.com meinte am 16.03.16 in alt.os.linux.slackware zum Thema Re: bash script problem ?:

>>
>> I agree that $() is better but ``'s can nest:=20
>>
>>     $ echo Year: `date \`echo +%Y\``
>>     Year: 2016

> That's spooky ! Who <associated> +%Y with "2016" ?
> Lets have some examples of nesting, without extra spooky-stuf.

See "sh-utils.info","Date directives"

I prefer looking in such files with "pinfo".

Viele Gruesse
Helmut

"Ubuntu" - an African word, meaning "Slackware is too hard for me".

[toc] | [prev] | [next] | [standalone]


#26515

FromRich <rich@example.invalid>
Date2016-03-16 17:43 +0000
Message-ID<ncc603$o0q$3@dont-email.me>
In reply to#26511
In alt.os.linux.slackware no.top.post@gmail.com wrote:
> In article <>, Teemu Likonen <tlikonen@iki.fi> wrote: 

> > 
> > rich@example.invalid [2016-03-10 15:22:57Z] wrote:
> > 
> > > Step 1, don't use the legacy sh backtick substitution syntax for
> > > this (because it cannot nest).  Use Bash's $() substitution
> > > instead (because it can nest).
> > 
> > I agree that $() is better but ``'s can nest:=20
> > 
> >     $ echo Year: `date \`echo +%Y\``
> >     Year: 2016
> > 
> That's spooky ! Who <associated> +%Y with "2016" ? Lets have some
> examples of nesting, without extra spooky-stuf.

Execute "man date" in a xterm - read the results - you will learn
something.

[toc] | [prev] | [standalone]


Back to top | Article view | alt.os.linux.slackware


csiph-web