O'Reilly logo

A Practical Guide to Red Hat® Linux® 8 by Mark G. Sobell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exercises

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required