LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 03: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, 03:33 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

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, 07:05 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

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

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
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, 07:27 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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, 07:33 PM   #6
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
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



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 09:40 AM
VPN failing on Ubuntu 10.04 machielr Linux - Networking 2 05-24-2010 03:45 AM
Ubuntu failing to load after splash? burgergetsbored Linux - Software 3 06-06-2009 05:45 PM
Execute commands via ssh - working and failing billlee Linux - Software 5 04-11-2009 07:40 AM
rpm and yum commands failing on CentOS 4.2 amussaw Linux - Newbie 1 03-21-2006 10:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:12 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
Open Source Consulting | Domain Registration