Accessing Files

Files can be created through editors, commands, redirection, or programs. The mechanism you choose to create a file should be based on your needs and abilities. Needless to say, you wouldn't create a file with the emacs editor if you were unfamiliar with emacs! An empty file can be created with the touch command.

The following example demonstrates several techniques for creating files:

 $ touch sm3 sm4 # Create two empty files $ $ ls -l sm* -rw-r--r-- 1 obrien guest 0 Nov 3 00:22 sm3 -rw-r--r-- 1 obrien guest 0 Nov 3 00:22 sm4 $ $ ls > sm5 # Create a small file through output redirection $ $ >sm6 # Shell creates an empty file whenever it sees > $ $ ls -l sm* -rw-r--r-- 1 obrien guest 0 Nov 3 00:22 sm3 -rw-r--r-- 1 obrien guest ...

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.