Why does “cat myfile >> myfile” cause infinite loop?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












Why does cat myfile >> myfile cause an infinite loop forcing me to kill the process?



my understanding is that this command
cat myfile >> myfile should simply do the following



  1. Read myfile and send file contents to stdout

  2. Redirect the contents of stdout and append to myfile

I would expect this to result in the contents of myfile to contain two copies of the original contents, appended together.









share









New contributor




James Wierzba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Possible duplicate of Why does cat x >> x loop?
    – don_crissti
    37 secs ago














up vote
0
down vote

favorite












Why does cat myfile >> myfile cause an infinite loop forcing me to kill the process?



my understanding is that this command
cat myfile >> myfile should simply do the following



  1. Read myfile and send file contents to stdout

  2. Redirect the contents of stdout and append to myfile

I would expect this to result in the contents of myfile to contain two copies of the original contents, appended together.









share









New contributor




James Wierzba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Possible duplicate of Why does cat x >> x loop?
    – don_crissti
    37 secs ago












up vote
0
down vote

favorite









up vote
0
down vote

favorite











Why does cat myfile >> myfile cause an infinite loop forcing me to kill the process?



my understanding is that this command
cat myfile >> myfile should simply do the following



  1. Read myfile and send file contents to stdout

  2. Redirect the contents of stdout and append to myfile

I would expect this to result in the contents of myfile to contain two copies of the original contents, appended together.









share









New contributor




James Wierzba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











Why does cat myfile >> myfile cause an infinite loop forcing me to kill the process?



my understanding is that this command
cat myfile >> myfile should simply do the following



  1. Read myfile and send file contents to stdout

  2. Redirect the contents of stdout and append to myfile

I would expect this to result in the contents of myfile to contain two copies of the original contents, appended together.







bash cat stdout





share









New contributor




James Wierzba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share









New contributor




James Wierzba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share



share








edited 25 secs ago









Rui F Ribeiro

37.1k1274118




37.1k1274118






New contributor




James Wierzba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 mins ago









James Wierzba

1012




1012




New contributor




James Wierzba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





James Wierzba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






James Wierzba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • Possible duplicate of Why does cat x >> x loop?
    – don_crissti
    37 secs ago
















  • Possible duplicate of Why does cat x >> x loop?
    – don_crissti
    37 secs ago















Possible duplicate of Why does cat x >> x loop?
– don_crissti
37 secs ago




Possible duplicate of Why does cat x >> x loop?
– don_crissti
37 secs ago















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






James Wierzba is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f475889%2fwhy-does-cat-myfile-myfile-cause-infinite-loop%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes








James Wierzba is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















James Wierzba is a new contributor. Be nice, and check out our Code of Conduct.












James Wierzba is a new contributor. Be nice, and check out our Code of Conduct.











James Wierzba is a new contributor. Be nice, and check out our Code of Conduct.













 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f475889%2fwhy-does-cat-myfile-myfile-cause-infinite-loop%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)