All Linux servers have a useful feature that is only one character long. The character is >
, and it makes saving command output to files extremely easy. It can make interpreting long command output data much easier and less time consuming.
For example, if you wanted to list the entire contents of /usr/lib, you could always run ls /usr/lib, but what you will get are pages of files and directories, probably more than your terminal window will even buffer. To solve this, all you have to do is add a >
to the end of the command, followed by the location and name of a new file that will hold the information.
For example, you could save the contents to a file in /home/user and call the text file “libraries”. This assumes that the file does not already exist. If it does, >
will overwrite it. Enter the following:
ls /usr/lib
>
/home/user/libraries
If you already have a file created with data inside and just want to append more data onto the end, add a second >
ls /usr/lib
> >
/home/user/libraries
Photo Source: Flickr