Outputting command to a text file

Andrew L. Gould algould at datawok.com
Thu Nov 11 19:20:45 GMT 2004


On Thursday 11 November 2004 01:08 pm, CHris Rich wrote:
> I want to use the du command to check on the sizes of files in a
> directory, but i want the output to be put into a text file so I can
> look at it later.
>
> I did some search on google, and found nothing that applied.
> Searched other places (lists and things) and couldn't find what i was
> looking for, perhaps i was using the wrong search terms.
>
> Any help will be greatly appreciated
>
> Thanks

You can redirect the output of commands into files using '>' and '>>'.

du > du_results.txt

The command above will send the output of du to the file du_results.txt  
The command creates du_results.txt, overwriting it if it already 
exists.

To append results to existing files, use '>>'.

du >> du_results

This, and other cool information can be found in the man page for your 
chosen shell.

Best of luck,

Andrew


More information about the freebsd-questions mailing list