#1  
Old 17th June 2005, 18: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
  #2  
Old 20th June 2005, 12: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, 22: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
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 13:20.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Sponsored Links: Unified Communications: Thoughts, Strategies and Predictions
Join the discussion.
www.seamlessenterprise.com

IP Convergence
Integrate your wireless and wireline networks.
Learn how from the experts at Sprint.
www.seamlessenterprise.com

Wireless & Wireline Integration
Thoughts, strategies and solutions: join the discussion
www.seamlessenterprise.com

Unified Communications 2009
Join the Discussion. Now.
www.seamlessenterprise.com

Red Hat Virtual Experience - a free virtual event. Dec. 9th