How to Save Command Output to a File in Linux

By | May 16, 2018

There are many things you can do with the output of a command in Linux. You can assign the output of a command to a variable, send it to another command/program for processing through a pipe or redirect it to a file for further analysis.

In this short article, I will show you a simple but useful command-line trick: how to view output of a command on the screen and also write to a file in Linux.

Viewing Output On Screen and also Writing to a File

Assuming you want to get a full summary of available and used disk space of a file system on a Linux system, you can employ the df command; it also helps you determine the file system type on a partition.

df

With the -h flag, you can show the file system disk space statistics in a “human readable” format (displays statistics details in bytes, mega bytes and gigabyte).

df -h

Now to display the above information on the screen and also write it to a file, say for later analysis and/or send to a system administrator via email, run the command below.

df -h | tee df.log

cat df.log

Here, the magic is done by the tee command, it reads from standard input and writes to standard output as well as files.

www.pdf24.org    Send article as PDF   
Category: VPS

2 thoughts on “How to Save Command Output to a File in Linux

  1. augmentin duo 375

    How this would be done without violating the attorney client privilege or the work product immunity is not explained augmentin class Bruynseels J, De Coster R, Van Rooy P, Wouters W, Coene MC, Snoeck E, Raeymaekers A, Freyne E, Sanz G, Vanden Bussche G R75251, a new inhibitor of steroid biosynthesis

Leave a Reply

Your email address will not be published. Required fields are marked *