3.12. Absolute and Relative PathnamesBefore I continue with the sample Linux session, it's important to introduce you to the idea of pathnames .
Two files in the same directory may not have the same
Figure 3-9. Different files may have the same name.
Although these files have the same name, they may be unambiguously specified by their
pathname
relative to "/," the root of the directory hierarchy. A pathname is a sequence of directory
Figure 3-10. Absolute pathnames.
A process may also unambiguously specify a file by using a pathname relative to its current working directory. The Linux file system supports special fields that may be used when supplying a relative pathname (Figure 3-11). Figure 3-11. Current and parent directories.(This item is displayed on page 54 in the print version)
For example, Figure 3-12 shows the pathnames of the three instances of "myFile" relative to the "ksh" process located in the "/home/glass" directory. Figure 3-12. Relative pathnames.
Note that the pathname "myFile" is equivalent to "./myFile," but the second form is usually not used unless you need to specify a command in your current directory when "." is not in your search
|
3.13. Creating a FileI already had an idea of what the first draft of my song's lyrics would look like, so I decided to store them in a file called "heart." Ordinarily, I would use a Linux editor such as vim or emacs to create the file, but this is a beginner's chapter, so I used a simpler utility called cat to achieve the same result. Figure 3-13 describes how cat works. Figure 3-13. Description of the cat command.
By default, the
standard input
of a process is the keyboard and the
standard output
is the screen. We can send the standard output of a process to a file instead of the screen by making use of a shell facility called
output redirection
. If you follow a command by a
>
character and the
$ cat > heart ...store keyboard input a the file 'heart'. I hear her breathing, I'm surrounded by the sound. Floating in this secret place, I never shall be found. ^D ...tell cat that the end-of-input has been reached. $ _ |