# How to Save Command Output to a File in Linux?

Operating SystemLinuxMCA

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

Published on 03-Jan-2020 07:00:58