
- Operating System Tutorial
- OS - Home
- OS - Overview
- OS - Components
- OS - Types
- OS - Services
- OS - Properties
- OS - Processes
- OS - Process Scheduling
- OS - Scheduling algorithms
- OS - Multi-threading
- OS - Memory Management
- OS - Virtual Memory
- OS - I/O Hardware
- OS - I/O Software
- OS - File System
- OS - Security
- OS - Linux
- OS - Exams Questions with Answers
- OS - Exams Questions with Answers
- Operating System Useful Resources
- OS - Quick Guide
- OS - Useful Resources
- OS - Discussion
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 Articles
- Display Command Output or File Contents in Column Format in Linux
- How to save MySQL query output to excel or .txt file?
- Writing Text to File Using Linux Cat Command
- How to encrypt and decrypt a file using gpg command on linux
- 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 output colored text to a Linux terminal?
- How to save the str output as a string in R?
- How to use diff Command in Linux
- How to Run a Command Multiple Times in Linux?
- How to save a Python Dictionary to CSV file?
- How to Change Terminal Output Color in Linux?
- How to save canvas data to file in HTML5?
- How to work with Invoke-Command Scriptblock output?
- How to save files using a File Chooser in JavaFX?

Advertisements