HP Workstation zx2000 HP Graphics Administration Guide for HP-UX 11.X (IPF ver - Page 7

path names, finding files with “whence” and “whereis”

Page 7 highlights

2 path names This chapter contains information on locating files that reside in the file system. finding files with "whence" and "whereis" There are two main methods of finding commands if you know the name of the command you're looking for. The first method is to use the Korn shell command whence, which tells you where a command resides. If you're not using the Korn shell, you can use the system command whereis. To use whence, enter: $ whence mknod The path for the command you're looking for is returned: /etc/mknod The above approach has two limitations: ■ Both whence and whereis only find executable files; that is, commands (both compiled programs and shell scripts). whence and whereis do not find non-executable files, even if they are in your PATH. To find nonexecutable files, use find, which is described in the next section. ■ The directory in which the command resides must be one of the entries in the PATH variable; if it is not, it won't be found. So in a sense, whence and whereis can only find things if you tell them where to look. They are valuable when a command is in your PATH but you do not remember where it is. Also, if you have two commands of the same name in two different directories, whence and whereis tell you which one will be found first, and thus executed. finding files with "find" The find command finds any file in your file system, executable or not. For example, to locate an include file, you would execute: $ find / -name '' where is the name of the file you're looking for. In this example, "/" is the root directory. If you specify the correct file name, and it is somewhere in the file system, the find command will find it, though it make take a while. You can shorten the search time by including a subdirectory. For example: find /opt -name '' searches only the /opt directory. You also can specify a partial filename. The find command locates all files that contain a specified substring in their names. find has many other options for refining a search; see the man page for details. Graphics Administration Guide 2-1

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66

Graphics Administration Guide
2–1
2
path names
This chapter contains information on locating files that reside in the file system.
finding files with “whence” and “whereis”
There are two main methods of finding commands if you know the name of the command you’re
looking for. The first method is to use the Korn shell command
whence
, which tells you where
a command resides. If you’re not using the Korn shell, you can use the system command
whereis
. To use whence, enter:
$ whence mknod
The path for the command you’re looking for is returned:
/etc/mknod
The above approach has two limitations:
Both
whence
and
whereis
only find executable files; that is, commands (both compiled
programs and shell scripts).
whence
and
whereis
do not find non-executable files, even
if they are in your PATH. To find nonexecutable files, use
find
, which is described in the
next section.
The directory in which the command resides must be one of the entries in the PATH variable;
if it is not, it won’t be found. So in a sense,
whence
and
whereis
can only find things if
you tell them where to look. They are valuable when a command is in your PATH but you do
not remember where it is. Also, if you have two commands of the same name in two different
directories,
whence
and
whereis
tell you which one will be found first, and thus
executed.
finding files with “find”
The
find
command finds any file in your file system, executable or not. For example, to locate
an include file, you would execute:
$ find / -name ’<
file_name
>’
where <
file_name
> is the name of the file you’re looking for. In this example, “/” is the root
directory. If you specify the correct file name, and it is somewhere in the file system, the
find
command will find it, though it make take a while. You can shorten the search time by including
a subdirectory. For example:
find /opt -name ’<
file_name
>’
searches only the
/opt
directory.
You also can specify a partial filename. The
find
command locates all files that contain a
specified substring in their names.
find
has many other options for refining a search; see the man page for details.