LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-24-2008, 07:43 AM   #1
imkornhulio
Member
 
Registered: Aug 2008
Posts: 58

Rep: Reputation: 15
echo problem


I need the output of the following code in one line please help.

echo 'H,Shoes,' ; date +%Y%m%d

Right now i get output like below
H,Shoes,
20081024

I want output to look like this

H,Shoes,20081024


Please help
 
Old 10-24-2008, 08:04 AM   #2
burschik
Member
 
Registered: Jul 2008
Posts: 159

Rep: Reputation: 31
Code:
echo -n 'H,Shoes,' ; date +%Y%m%d
 
Old 10-24-2008, 08:13 AM   #3
imkornhulio
Member
 
Registered: Aug 2008
Posts: 58

Original Poster
Rep: Reputation: 15
Thanks for the help. I quick questiion if i want to take that output and append to another file i only add >> and the file name at the end of the code right?

echo -n 'H,Shoes,' ; date +%Y%m%d >> test.csv

Please help!

Last edited by imkornhulio; 10-24-2008 at 08:33 AM.
 
Old 10-24-2008, 08:53 AM   #4
imkornhulio
Member
 
Registered: Aug 2008
Posts: 58

Original Poster
Rep: Reputation: 15
Someone Please Help!!!
 
Old 10-24-2008, 08:58 AM   #5
olilogu
LQ Newbie
 
Registered: Oct 2008
Location: EST USA
Posts: 3

Rep: Reputation: 0
Smile Use echo

You can use:
echo 'H,Shoes,' ` date +%Y%m%d`
 
Old 10-24-2008, 09:01 AM   #6
burschik
Member
 
Registered: Jul 2008
Posts: 159

Rep: Reputation: 31
Quote:
Originally Posted by imkornhulio View Post
Thanks for the help. I quick questiion if i want to take that output and append to another file i only add >> and the file name at the end of the code right?

echo -n 'H,Shoes,' ; date +%Y%m%d >> test.csv

Please help!
Not quite.

Code:
{ echo -n 'H,Shoes,' ; date +%Y%m%d; } >> test.csv
 
Old 10-24-2008, 09:03 AM   #7
imkornhulio
Member
 
Registered: Aug 2008
Posts: 58

Original Poster
Rep: Reputation: 15
Thanks a Ton
 
Old 10-24-2008, 02:39 PM   #8
jan61
Member
 
Registered: Jun 2008
Posts: 235

Rep: Reputation: 47
Moin,

Quote:
Originally Posted by burschik View Post
Code:
{ echo -n 'H,Shoes,' ; date +%Y%m%d; } >> test.csv
why not simply call
Code:
echo "H,Shoes,$(date +%Y%m%d)" >>test.csv
?

Jan
 
Old 10-24-2008, 03:41 PM   #9
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Even more simply:
Code:
date +H,Shoes,%Y%m%d >> test.csv
 
  


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
echo problem shan_nathan Programming 3 04-24-2008 10:48 AM
ls | echo, I got blank, why can't echo take the 2nd seat in a pipeline? elinuxqs Linux - Newbie 6 11-24-2006 08:25 AM
echo problem kponenation Slackware 3 06-10-2006 09:53 AM
Kphone echo (echo echo) scabies Linux - Software 0 10-18-2004 02:59 PM
Echo /devPrinting doesn't work, echo /usb/lp0 works, Testpage works, Printing doesn't Hegemon Linux - General 3 08-15-2002 01:13 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:09 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