Linux › Section K · Shell scripts › Topic K.7

Subshells, including files, and reading input

Three features decide where a script's commands run and where its data comes from: subshells give a throwaway copy of the environment, sourcing pulls another file into the current shell, and read takes input from the user. Shell functions, which package commands under a name, complete the toolkit.

In this topic

  • Subshells: a disposable environment
  • One-off environment changes
  • Subshells you did not ask for
  • Worked example: copying a tree through a pipe
  • Including other files with . and source
  • Reading input with read
  • Worked example: an "Are you sure?" prompt
  • Shell functions
  • Worked example: a validating function
  • Common mistakes to avoid
  • Key takeaways

This topic is part of Wuanberri Pro. Checking your access…

← Previous topicNext topic →