- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to Save Command Output to a File in Linux?
Sometimes the output of Unix command can we learn the important in such case we want to save the result for later reference in this article we will see how to save the output of a command to a file.
Creating a New File
Output of the disk usage command can be saved by using the > symbol and a new file name.
$du-h > usagefile.txt $cat usagefile.txt
Running the above code gives us the following result −
12K./bin 4.0K./Videos 20K./.compiz/session 24K./.compiz 8.0K./.config/gedit 12K./.config/compiz-1/compizconfig ………… ……….
Appending to Existing File
Append the Output of the disk usage command by using the >> symbol and a new file name.
$du-h >> usagefile_all_dates.txt $cat usagefile_all_dates.txt
Running the above code gives us the following result −
12K./bin 4.0K./Videos 20K./.compiz/session 24K./.compiz 8.0K./.config/gedit 12K./.config/compiz-1/compizconfig ………… ……….
Display and Save to a File
Append the Output of the disk usage command by using the >> symbol and a new file name.
$du-h | tee bigusagefile.txt
Advertisements