Linux - File I/O operations from terminal
Table of Contents
How To Save Terminal Output To A File
How do I save the output of a command to a file?
Yes it is possible, just redirect the output to a file:
SomeCommand > SomeFile.txt
This could be a very easy way to create a catalog for a directory instead of running programs to list the contents of the directory. e.g. Go to the folder for which you are trying to create the catalog and run this command : tree > 00Catalog.txt (to create a file called 00Catalog.txt in that directory)
See View Directories and Files in a Tree Structure
How to clear the contents of a file from the command line?
You can use the user command : truncate
truncate -s 0 test.txt
(-s 0
to specify the size)