

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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
- Related Questions & Answers
- Display Command Output or File Contents in Column Format in Linux
- How to save MySQL query output to excel or .txt file?
- How to encrypt and decrypt a file using gpg command on linux
- How to output colored text to a Linux terminal?
- How to get only the file name using find command on Linux?
- How to send a file as an email attachment using the Linux command line?
- How to use diff command in linux
- How to save a Python Dictionary to CSV file?
- How to save the str output as a string in R?
- How to use a pipe with Linux find command?
- How to save HTML5 canvas data to file?
- How to work with Invoke-Command Scriptblock output?
- How to save canvas data to file in HTML5?
- How to save files using a File Chooser in JavaFX?
- How to save a vector in R as CSV file?
Advertisements