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.
If a file(s) already exists, you can append it using the -a
or --append
option like this.
$ df -h | tee -a df.log