about quote in command
Todd Zullinger
tmz at pobox.com
Thu Dec 6 18:53:42 UTC 2007
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 542 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20071206/941905d7/attachment-0001.sig>
More information about the fedora-list
mailing list