Re: about quote in command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Gijs wrote:
> adrian kok wrote:
>> Hi all
>>
>> how can I make the quote correct?
>>
>> `tail -n 1 `date "+%Y-%m-%d-%H"`.txt`
>>
>> `date "+%Y-%m-%d-%H"`.txt is file
>>
>> thank you
>>
>> Send instant messages to your online friends http://uk.messenger.yahoo.com 
>>
>>   
> Well, as far as I know this works:
> tail -n 1 $(date "+%Y-%m-%d-%H").txt
> tail -n 1 `date "+%Y-%m-%d-%H"`.txt

Right.  You can't nest the backticks.  How would the shell know which
one was meant to be the start of a command and which was the end?

Bash has the $() syntax which allows for nesting of multiple commands.
Be aware that if you use that syntax, you should change the #! in your
script from /bin/sh to /bin/bash if you're concerned about the script
being portable to systems where /bin/sh and /bin/bash are not always
the same.

Adrian, what you want can be written like this:

$(tail -n 1 $(date "+%Y-%m-%d-%H").txt)

-- 
Todd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Money frees you from doing things you dislike. Since I dislike doing
nearly everything, money is handy.
    -- Groucho Marx

Attachment: pgpFVnja9nfSK.pgp
Description: PGP signature


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux