Sams Teach Yourself Shell Programming in 24 Hours
(Publisher: Macmillan Computer Publishing)
Author(s): Sriranga Veeraraghavan
ISBN: 0672314819
Publication Date: 01/01/99
Summary
In this chapter, you covered the following topics:
- Listing files using ls
- Viewing the content of a file using cat
- Counting the words, lines, and characters in a file using wc
- Copying files using cp
- Renaming files using mv
- Removing files using rm
Knowing how to perform each of these tasks is essential to becoming a good shell programmer. In the chapters ahead you use these basics to create scripts for solving real world problems.
Questions
- 1. What are invisible files? How do you use ls to list them?
- 2. Will there be any difference in the output of the following commands?
- a. $ ls -a1
- b. $ ls -1 -a
- c. $ ls -1a
- 3. Which options should be specified to wc in order to count the number of lines and characters in a file?
- 4. Given that hw1, hw2, ch1, and ch2 are files and book and homework are directories, which of the following commands generates an error message?
- a. $ cp hw1 ch2 homework
- b. $ cp hw1 homework hw2 book
- c. $ rm hw1 homework ch1
- d. $ rm hw2 ch2
Terms
- ls
- The command that lists the files in a directory.
- cat
- The command that views the contents of a file.
- wc
- The command that counts the words, lines, and characters in a file.
- cp
- The command that copies files.
- mv
- The command that renames files.
- rm
- The command that removes files.
- Ordinary File
- A file on the system that contains data, text, or program instructions.
- Directories
- A type of file that stores other files. For users familiar with Windows or Mac OS, UNIX directories are equivalent to folders.
- Invisible Files or Hidden Files
- Files whose names start with the . character. By default the ls command does not list these files. You can list them by specifying the -a option to ls.