Shell and Terminal
A terminal provides an interface for entering text and displaying output. A shell interprets command language and runs commands. Bash and zsh are shells; Linux is an operating-system environment. A terminal window can run different shells, and a shell script can run without an interactive terminal.
Before an external program runs, the shell can expand variables and filename patterns, arrange redirections, and determine the arguments passed to it. This explains why quoting changes behavior. If a variable contains a directory name with a space, an unquoted expansion in Bash can become more than one argument. Zsh does not split unquoted parameter expansions by default unless the SH_WORD_SPLIT option is set, so check which shell and options are in effect. Double quotes preserve that value as one argument in either shell while still allowing variable expansion.
Commands also depend on context. A relative path is interpreted from the current working directory. An external command name without a slash is normally found through PATH, although a shell may first resolve an alias, function, or builtin. A job started by a scheduler can have a different directory, environment, and account from an interactive session.
When a command works in a terminal but fails in a job, compare those contexts and the actual shell before changing the data. Explicitly launching Bash selects Bash semantics; a scriptโs shebang is used when the script is executed directly, but running it through a different interpreter selects that interpreter instead. Quoting keeps argument boundaries intact; it does not validate that a path is the intended one.
Practice these ideas in Linux, the Shell, and Git for Data Work.
References
Discover more from Insightful Data Lab
Subscribe to get the latest posts sent to your email.
