#1  
Old 17th June 2005, 17:42
torben torben is offline
Junior Member
 
Join Date: May 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Echo into a file

I've found 2 slightly different syntaxes for redirecting the output of echo into a file on the shell:

Code:
echo "something" > file
and

Code:
echo "something" >> file
What's the difference between these 2 commands?
Reply With Quote
Sponsored Links
  #2  
Old 20th June 2005, 11:29
jojo jojo is offline
Junior Member
 
Join Date: Apr 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code:
echo "something" > file
means that everything that's in "file" will be deleted, and "something" will be written to it (which means that "something" will be right at the beginning of "file".

Code:
echo "something" >> file
means that "something" will be appended to "file", so nothing will be deleted from "file", and "something will be at the end of "file".

"file" will be created if it doesn't exist in both cases.

A little example:

We have the file "file" with the following contents:

Code:
line 1
line 2
line 3
Now when you execute the command

Code:
echo "something" > file
the content of "file" will be

Code:
something
When you run

Code:
echo "something" >> file
instead, the content of "file" will be

Code:
line 1
line 2
line 3
something
jojo
Reply With Quote
  #3  
Old 16th August 2005, 21:00
linutzy linutzy is offline
Member
 
Join Date: Jul 2005
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default >> means append

You are just addiing to the file as stated above.
Reply With Quote
  #4  
Old 6th January 2010, 12:23
JulietteKlonk JulietteKlonk is offline
Junior Member
 
Join Date: Dec 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you for the informative post and keep up the good work!
__________________
JCB
Reply With Quote
  #5  
Old 21st October 2010, 08:41
masterdam79 masterdam79 is offline
Junior Member
 
Join Date: Oct 2010
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Echo to another server

Just wondering how to echo to another (fingerprinted) server?

Code:
echo "something" >> user@server:file
or

Code:
ssh user@server echo "something" >> file
Doesn't seem to work..
Reply With Quote
  #6  
Old 21st October 2010, 09:37
Franz Franz is offline
Senior Member
 
Join Date: Jul 2009
Location: Cakovec
Posts: 117
Thanks: 7
Thanked 24 Times in 18 Posts
Send a message via Skype™ to Franz
Default

use variable:
X_X="echo something >> file"
ssh user@server $X_X
__________________
my PAGE
VoIP
my IT help blog
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 03:53.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.