O'Reilly logo

Solaris™ 8 Advanced System Administrator's Guide, Third Edition by Janice Winsor

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

File Name Stripping

Sometimes you want to modify a path name in a script to strip off unneeded parts. With the Bourne shell, you can use the basename(1) command to return only the file name, and the dirname(1) command to return only the directory prefix. The Korn and C shells provide a built-in way for you to modify path names.

Korn Shell Path Stripping

The Korn shell provides pattern-matching operators, shown in Table 81, that you can use to strip off components of path names.

Table 81. Korn Shell Pattern-Matching Operators
Operator Description
${variable# pattern} Delete the shortest part at the beginning of the variable that matches the pattern and return the rest.
${variable## pattern} Delete the longest part at the beginning of the variable ...

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