Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 01-05-2011, 09:33 AM   #1
Registered: Nov 2010
Posts: 87

Rep: Reputation: 1
Smile confusing behaviour of a command


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, 09:46 AM   #2
Senior Member
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613
You used two >s in the second. ">>" means "append," so no overwriting occurs.
Old 01-05-2011, 12:26 PM   #3
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.


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

All times are GMT -5. The time now is 02:16 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration