You want to quickly create a file with some text, or record a directory listing into a file.
Use the > command to redirect output that would otherwise appear on the command line.
For example, to copy a directory listing into a file called myfiles.txt, do the following:
$ ls > myfiles.txt $ more myfiles.txt Desktop indiecity master.zip mcpi |
Discussion
You can use the > command on any Linux command that produces output, even if you are running, say, a Python program.
You can also use the opposite < command to redirect user input, although this is not nearly as useful as >.
See Also
To use > to join together a number of files, see Recipe 3.28.