Summary

In this chapter, you learned how to determine which version of UNIX is running using uname. In addition, you developed the getOSName and isOS functions to help adapt shell scripts to multiple versions of UNIX. You also looked at the following techniques for improving the portability of shell scripts:

  • Conditional execution

  • Abstraction

In conditional execution, the flow of a script was modified depending on the version of UNIX being used. In abstraction, function implementations were altered to account for the differences between versions of UNIX; the overall flow of the script remained the same.

Using the techniques and tips in this chapter, you can port shell scripts across different versions of UNIX.

Get Sams Teach Yourself Shell Programming in 24 Hours, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.