Commands

Commands

basename

NAME [SUFFIX]

This command takes a full UNIX path and displays only the last element. It is generally used in scripting. If the optional suffix is supplied and it matches the last element, it is stripped away as well.

Example: Suppose your current working directory is /var/spool/ mail. In that case,

basename $PWD

would display

mail

Of course, basename can be used on text strings as well as environment variables, and

basename /var/spool/mail

would also display

mail

--help

Display usage information.

--version

Display version information.

dirname

NAME

This command takes a full UNIX path and displays all but the last element. The command is generally used in scripting.

Example: Suppose you were writing a script that needed to know the directory name of your mail folder. In that case, use

dirname $MAIL

graphics/tip.gif

This command is a good example of a general scripting principle: don't hard code. "Hard coding" means treating a value in your script (e.g., the mail directory, /var/spool/mail) as a constant when it may not necessarily be constant.

 

For example, while /var/spool/mail is in fact a wise choice for a mail directory, I can flat out promise you that the systems administrator of the company to whom you are pitching your million-dollar mail utility chose instead to specify /random/directory. I can further promise that you won't notice this until the board of directors is assembled to review your program.

--help

Display usage information.

--version

Display version information.

namei

[-mx] pathname [ pathname ]

When passed a standard UNIX path, namei will follow the path until a terminal point is found. If a symbolic link is in the path, namei follows that as well. This command is generally used for identifying excessive symbolic links (links to links to links to ). Output uses the following abbreviations:

f

The pathname we are currently trying to resolve

d

Directory

l

Symbolic link (both the link and its contents are output)

s

Socket

b

Block device

c

Character device

-

Regular file

?

Error

Example: Suppose linkfile was a link to /usr/local. Then

namei linkfile/hawksoft

would yield the following:

f: linkfile/hawksoft
l linkfile -> /usr/local
d /
d usr
d local
d hawksoft

-x

Display mount point directories as a "D".

-m

Include the mode of each file in the display.

pathchk

[OPTION] NAME

Check the portability and validity of any specified path. Displays an error if any of the following conditions is met:

1.       A directory in NAME does not have execute permission.

2.       The length of NAME exceeds the filesystem's name length limits.

3.       The length of any component of NAME exceeds the filesystem's component length limits.

Example: To check the portability of your "baby" before sending it out into the world:

pathchk /usr/local/hawksoft/eft-o-matic

-p,--portability

Test against the POSIX minimum limits for portability.

 



Linux Desk Reference
Linux Desk Reference (2nd Edition)
ISBN: 0130619892
EAN: 2147483647
Year: 2000
Pages: 174
Authors: Scott Hawkins

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net