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: pgpz4Bt3JrHfr.pgp
Description: PGP signature

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux