How to Save Command Output to a file in Linux

Command is an instruction given by a user to perform a particular tasks in linux. Commands are generally used by typing them in at command line interface and pressing Enter key, which passes it to the shell. Shell is a program that reads command and execute it.   In this small topics we will discuss how to save command output to a file in linux. A command consists of command name followed by one or more strings. The general sysntx of command is given below –

Execute a command through command line – 

Here i am going to execute a simple command through command line. df command shows filesystem disk uses. -h flag is used for human readable.

Now i am going to save output of command to a file . For this you can use “>

you can view your output through cat command . 

Through above method you can directly save your output to a file . But If you want viewing output on screen and save output to a file , you can use tee command.

Now you can check your file for viewing output

you can use -a flag , if file is already exists. -a is used for append.

Through this topics i explained how to save command output to a file in linux . Please subscribe to newsletter for updated articles. We will discuss about many other topics in next articles.