something wrong when overwriting file [duplicate]What are the shell's control and redirection operators?Do...

How should I push back against my job assigning "homework"?

How to provide realism without making readers think grimdark

Show sparse matrices like chessboards

Unconventional Opposites

Sucuri detects malware on wordpress but I can't find the malicious code

What's the most polite way to tell a manager "shut up and let me work"?

What is the right way to float a home lab?

Please help me identify this plane

Is there a rule that prohibits us from using 2 possessives in a row?

How can a single Member of the House block a Congressional bill?

Metal bar on DMM PCB

Initialize an array of doubles at compile time

Creating Fictional Slavic Place Names

Does Peach's float negate shorthop knockback multipliers?

Access to all elements on the page

GFCI Outlet in Bathroom, Lights not working

Pros and cons of writing a book review?

What people are called boars ("кабан") and why?

Is American Express widely accepted in France?

Is it possible to kill all life on Earth?

The term for the person/group a political party aligns themselves with to appear concerned about the general public

Applicants clearly not having the skills they advertise

Hygienic footwear for prehensile feet?

How is it possible for this NPC to be alive during the Curse of Strahd adventure?



something wrong when overwriting file [duplicate]


What are the shell's control and redirection operators?Do redirection operators always open file descriptors in parallel?How can I maintain line breaks in body text with mailx when sending attachments?Add text with echo but start with new line if file not emptyBASH: Fifo troubles - seems selective about inputDifferent behavior in shell script vs in shell?How to pass the contents of a file to an option/parameter of a functionHow to change/fix the v command in less using a shell profile?Create a menu driven script with do loop and case statement in bashHow do I search a file for a pattern, then extract part of the pattern or supply a default if the pattern does not exist?Unable to redirect output to file from certain commandsWriting continuously to named pipe






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0
















This question already has an answer here:




  • What are the shell's control and redirection operators?

    3 answers



  • Do redirection operators always open file descriptors in parallel?

    2 answers




I was trying to delete the last line and overwrite the file. But I failed for some reason. I could write the modified text to another file though.



$cat > file.txt
a
b
c

$set "$d" file.txt > file2.txt
$cat file2.txt
a
b


however when I enter this:



$set "$d" file.txt > file.txt
$cat file.txt


It shows nothing meaning file.txt is empty now.
I wonder why this happens?










share|improve this question







New contributor



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










marked as duplicate by Scott, icarus, Community 10 mins ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • See Warning regarding ‘‘>’’.

    – Scott
    39 mins ago


















0
















This question already has an answer here:




  • What are the shell's control and redirection operators?

    3 answers



  • Do redirection operators always open file descriptors in parallel?

    2 answers




I was trying to delete the last line and overwrite the file. But I failed for some reason. I could write the modified text to another file though.



$cat > file.txt
a
b
c

$set "$d" file.txt > file2.txt
$cat file2.txt
a
b


however when I enter this:



$set "$d" file.txt > file.txt
$cat file.txt


It shows nothing meaning file.txt is empty now.
I wonder why this happens?










share|improve this question







New contributor



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










marked as duplicate by Scott, icarus, Community 10 mins ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • See Warning regarding ‘‘>’’.

    – Scott
    39 mins ago














0












0








0









This question already has an answer here:




  • What are the shell's control and redirection operators?

    3 answers



  • Do redirection operators always open file descriptors in parallel?

    2 answers




I was trying to delete the last line and overwrite the file. But I failed for some reason. I could write the modified text to another file though.



$cat > file.txt
a
b
c

$set "$d" file.txt > file2.txt
$cat file2.txt
a
b


however when I enter this:



$set "$d" file.txt > file.txt
$cat file.txt


It shows nothing meaning file.txt is empty now.
I wonder why this happens?










share|improve this question







New contributor



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












This question already has an answer here:




  • What are the shell's control and redirection operators?

    3 answers



  • Do redirection operators always open file descriptors in parallel?

    2 answers




I was trying to delete the last line and overwrite the file. But I failed for some reason. I could write the modified text to another file though.



$cat > file.txt
a
b
c

$set "$d" file.txt > file2.txt
$cat file2.txt
a
b


however when I enter this:



$set "$d" file.txt > file.txt
$cat file.txt


It shows nothing meaning file.txt is empty now.
I wonder why this happens?





This question already has an answer here:




  • What are the shell's control and redirection operators?

    3 answers



  • Do redirection operators always open file descriptors in parallel?

    2 answers








shell-script






share|improve this question







New contributor



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










share|improve this question







New contributor



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








share|improve this question




share|improve this question






New contributor



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








asked 56 mins ago









Jack ChenJack Chen

1




1




New contributor



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




New contributor




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






marked as duplicate by Scott, icarus, Community 10 mins ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Scott, icarus, Community 10 mins ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • See Warning regarding ‘‘>’’.

    – Scott
    39 mins ago



















  • See Warning regarding ‘‘>’’.

    – Scott
    39 mins ago

















See Warning regarding ‘‘>’’.

– Scott
39 mins ago





See Warning regarding ‘‘>’’.

– Scott
39 mins ago










0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m