How To Output To a File In Linux?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1. Use the redirection operator ( > ) to output a command to a file. For example, to output the text “Hello world” to a file called hello.txt, you can type:
echo “Hello world” > hello.txt
2. Use the append redirection operator ( >> ) to append output to an existing file. For example, to append the text “Goodbye world” to hello.txt, you can type:
echo “Goodbye world” >> hello.txt
3. Use the tee command to output both to the terminal and to a file. For example, to output the text “Farewell world” to both the terminal and to hello.txt, you can type:
echo “Farewell world” | tee hello.txt