December 2002
Intermediate to advanced
1616 pages
39h 57m
English
| 1. | The dirname utility treats its argument as a pathname and writes to standard output the path prefix, that is, everything up to but not including the last component. Thus
dirname a/b/c/d writes a/b/c to standard output. If path is a simple filename (has no / characters), dirname writes a . to standard output. Implement dirname as a Z Shell function. Make sure that it behaves sensibly when given such arguments as /. |
| 2. | Implement the basename utility, which writes the last component of its pathname argument to standard output, as a Z Shell function. For example,
zsh % basename a/b/c/d
writes d to standard output. |
| 3. | The GNU/Linux basename utility has an optional second argument. If you type
basename path suffix basename removes the ... |
Read now
Unlock full access