FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora User

 
 
LinkBack Thread Tools
 
Old 12-06-2007, 04:59 PM
adrian kok
 
Default about quote in command

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

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 12-06-2007, 05:27 PM
Gijs
 
Default about quote in command

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
or somewhat harder:
temp=`date "+%Y-%m-%d-%H"`.txt && tail -n 1 $temp

Hope this works for you.

Regards

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 12-06-2007, 05:53 PM
Todd Zullinger
 
Default about quote in command

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

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 12-06-2007, 06:05 PM
"Mikkel L. Ellertson"
 
Default about quote in command

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
>
The problem is that the first ` matches the one at the start of the
date command, and not the one after .txt, so you have to use a
different method of running a command. You can substitute $() for
one pair of back quotes.

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

Another way to do it, especially if you need the name in more then
one place, is to do something like this:

file_name=$(date "+%Y-%m-%d-%H").txt

tail -n 1 $file_name

Mikkel
--

Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 12-06-2007, 06:11 PM
Sjoerd Mullender
 
Default about quote in command

On 2007-12-06 18:59, 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
>

All of these should work:

`tail -n 1 `date "+%Y-%m-%d-%H"`.txt`

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

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

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

--
Sjoerd Mullender

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 12-06-2007, 07:19 PM
Sjoerd Mullender
 
Default about quote in command

On 2007-12-06 20:11, Sjoerd Mullender wrote:
> On 2007-12-06 18:59, 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
>>
>
> All of these should work:
>
> `tail -n 1 `date "+%Y-%m-%d-%H"`.txt`
>
> $(tail -n 1 $(date "+%Y-%m-%d-%H").txt)
>
> $(tail -n 1 `date "+%Y-%m-%d-%H"`.txt)

I forgot to remove the backslashes here, it should be:
$(tail -n 1 `date "+%Y-%m-%d-%H"`.txt)

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


--
Sjoerd Mullender

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 12-06-2007, 11:52 PM
Charles Curley
 
Default about quote in command

On Thu, Dec 06, 2007 at 08:11:51PM +0100, Sjoerd Mullender wrote:
> On 2007-12-06 18:59, adrian kok wrote:
> > Hi all

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

This is the preferred syntax, because:

* The nesting problem others have noted.

* The `` syntax is deprecated and may eventually go away. It is
retained mainly for backward compatibility.

* $() will tickle parentheses matching tools in some editors such as
emacs, making the code easier to read.

--

Charles Curley /" ASCII Ribbon Campaign
Looking for fine software / Respect for open standards
and/or writing? X No HTML/RTF in email
http://www.charlescurley.com / No M$ Word docs in email

Key fingerprint = CE5C 6645 A45A 64E4 94C0 809C FFF6 4C48 4ECD DFDB
--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 

Thread Tools




All times are GMT. The time now is 12:50 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org