LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-31-2011, 04:14 AM   #1
greenpool
Member
 
Registered: Sep 2010
Posts: 41

Rep: Reputation: 0
Ubuntu: commands with ' ' are failing


hi,

the following appears to be failing. i hope someone can tell me why..

so i'm trying to create a file with the current date as the prefix in the following way (following instructions from a tutorial):

Code:
touch 'date +%F'.log
its creating the file as:

date +%F.log

instead of 2011-07-31.log

i also tried the following:

Code:
var='expr 1 + 2'
echo $var
now i thought it should display the result as 3 but instead its printing the string:

expr 1 + 2


what am i getting wrong/missing/failing to understand?

thanks!
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 07-31-2011, 04:33 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Use backticks instead of ticks
Code:
fortyfourgalena@desktop-01:~$ touch `date +%F`.log
fortyfourgalena@desktop-01:~$ ls 2011*
2011-07-31.log
fortyfourgalena@desktop-01:~$
 
2 members found this post helpful.
Old 07-31-2011, 08:05 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Or try $(); easier to read
Code:
touch $(date +%F).log
2011-08-01.log
 
Old 07-31-2011, 08:08 PM   #4
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
Quote:
Originally Posted by chrism01 View Post
Or try $(); easier to read
Code:
touch $(date +%F).log
2011-08-01.log
Normally, that would depend on the user. Me personally, I use both, but mainly I use backticks.
 
Old 07-31-2011, 08:27 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Yeah, I'm old school myself, but it is easier to read, especially across environments. I actually tested that on the Solaris system in front of me, just to see if it worked there.
 
Old 07-31-2011, 08:33 PM   #6
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
Quote:
Originally Posted by chrism01 View Post
Yeah, I'm old school myself, but it is easier to read, especially across environments. I actually tested that on the Solaris system in front of me, just to see if it worked there.
I could have told you that

And honestly, I don't think I will be ever considered "new school....."
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
GeForce4 MX 420 failing on Ubuntu 10.04 johnsfine Ubuntu 8 06-19-2010 10:40 AM
VPN failing on Ubuntu 10.04 machielr Linux - Networking 2 05-24-2010 04:45 AM
Ubuntu failing to load after splash? burgergetsbored Linux - Software 3 06-06-2009 06:45 PM
Execute commands via ssh - working and failing billlee Linux - Software 5 04-11-2009 08:40 AM
rpm and yum commands failing on CentOS 4.2 amussaw Linux - Newbie 1 03-21-2006 11:06 AM


All times are GMT -5. The time now is 01:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration