9.1. Introduction

When commands are executed from within a file, instead of from the command line, the file is called a shell script and the shell is running noninteractively. When the bash shell starts running noninteractively, it looks for the environment variable, BASH_ENV (ENV) and starts up the file (normally bashrc) assigned as its value. After the BASH_ENV file has been read, the shell will start executing commands in the script.[1]

[1] when bash starts interactively, in the -norc or --norc option is given, the BASH_ENV or ENV file will not be read.

9.1.1. The Steps in Creating a Shell Script

A shell script is normally written in an editor and consists of commands interspersed with comments. Comments are preceded by a pound sign and consist ...

Get Linux Shells by Example 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.