Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Unknown Newsgroups: alt.os.linux.slackware,comp.os.linux.misc,alt.os.linux.debian Subject: Re: bash script problem ? Date: Thu, 17 Mar 2016 11:00:14 -0000 (UTC) Organization: A noiseless patient Spider Lines: 46 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 17 Mar 2016 11:00:14 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="878ab2efada68a7f7a2b4b004f42f337"; logging-data="3246"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19BW1OjP8Q+L9Zomail5FcVbnL2Tq9YVko=" User-Agent: Pan/0.133 (House of Butterflies) Cancel-Lock: sha1:1u6BdwlQlCrJJrR0rsVRtHfZHVg= Xref: csiph.com alt.os.linux.slackware:26517 comp.os.linux.misc:17037 alt.os.linux.debian:7909 On Wed, 16 Mar 2016 17:08:56 +0000, William Unruh wrote: > On 2016-03-16, no.top.post@gmail.com wrote: >> In article <>, Teemu Likonen 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 +%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.