LinuxQuestions.org
Visit Jeremy's Blog.
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 01-05-2011, 08:33 AM   #1
aggrishabh
Member
 
Registered: Nov 2010
Posts: 87

Rep: Reputation: 1
Smile confusing behaviour of a command


Hi,

command cat 1.txt>1.txt leaves the file 1.txt blank because shell first opens the target file then execute the command, here shell overwrite the file 1.txt which is treated as new file.

if that is so then the output of this command should also be same

cat 1.txt>>1.txt
but result is not same. Please explain this, and correct me if i am wrong.
 
Old 01-05-2011, 08:46 AM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,822

Rep: Reputation: 610Reputation: 610Reputation: 610Reputation: 610Reputation: 610Reputation: 610
You used two >s in the second. ">>" means "append," so no overwriting occurs.

http://www.gnu.org/software/bash/man...l#Redirections
 
Old 01-05-2011, 11:26 AM   #3
aggrishabh
Member
 
Registered: Nov 2010
Posts: 87

Original Poster
Rep: Reputation: 1
Thanx for replying.

My confusion was, the content in the file 1.txt should appear two times(same content), but here with second command no modification in file occurs not even the timestamp.
 
  


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
more command strange behaviour sancho1980 Linux - Newbie 2 03-12-2008 07:05 AM
php: echo command behaviour ChrisScott Programming 2 08-04-2007 07:28 PM
Unexpected behaviour with the find command dazdaz Linux - General 3 12-15-2004 08:50 PM
Confusing find command davidas Linux - Newbie 1 03-24-2004 06:26 AM
so confusing c12ayon Programming 5 10-26-2003 11:52 PM


All times are GMT -5. The time now is 06:56 AM.

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