Skip to main content

Sh Programming

  • 229k Accesses

Abstract

This chapter covers sh programming. It explains sh scripts and different versions of sh. It compares sh scripts with C programs and points out the difference between interpreted and compiled languages. It shows how to write sh scripts in detail. These include sh variables, sh statements, sh built-in commands, regular system commands and command substitution. Then it explains sh control statements, which include test conditions, for loop, while loop, do-until loop, case statements, and it demonstrates their usage by examples. It shows how to write sh functions and invoke sh functions with parameters. It also shows the wide range of applications of sh scripts by examples. These include the installation, initialization and administration of the Linux system.

The programming project is for the reader to write a sh scripts which recursively copies files and directories. The project is organized in a hierarchy of three sh functions; cpf2f() which copies file to file, cpf2d() which copies file into a directory and cpd2d() which recursively copies directories.

Keywords

  • Command Substitution
  • Including Test Statistics
  • Copy Files
  • Dd Cp
  • Command Group

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

This is a preview of subscription content, access via your institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • DOI: 10.1007/978-3-319-92429-8_10
  • Chapter length: 18 pages
  • Instant PDF download
  • Readable on all devices
  • Own it forever
  • Exclusive offer for individuals only
  • Tax calculation will be finalised during checkout
eBook
USD   59.99
Price excludes VAT (USA)
  • ISBN: 978-3-319-92429-8
  • Instant PDF download
  • Readable on all devices
  • Own it forever
  • Exclusive offer for individuals only
  • Tax calculation will be finalised during checkout
Softcover Book
USD   74.99
Price excludes VAT (USA)
Hardcover Book
USD   109.99
Price excludes VAT (USA)

References

  • Bourne, S.R., The Unix System, Addison-Wesley, 1982

    Google Scholar 

  • Forouzan, B.A., Gilberg, R.F., Unix and Shell Programming, Brooks/Cole, 2003

    Google Scholar 

  • Wang, K.C., Design and Implementation of the MTX Operating System, Springer International Publishing AG, 2015

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and Permissions

Copyright information

© 2018 Springer International Publishing AG, part of Springer Nature

About this chapter

Verify currency and authenticity via CrossMark

Cite this chapter

Wang, K.C. (2018). Sh Programming. In: Systems Programming in Unix/Linux. Springer, Cham. https://doi.org/10.1007/978-3-319-92429-8_10

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-92429-8_10

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-92428-1

  • Online ISBN: 978-3-319-92429-8

  • eBook Packages: Computer ScienceComputer Science (R0)