The bash is the main command line interface in Linux systems. These articles don't want to explain it totally, but simply to present its fundamental aspects synthetically and schematically, focusing mainly on the script realization. It's assumed that the reader already knows at least basically Linux systems. All the scripts were tested on Ubuntu / Kubuntu distributions.
When the bash is started (typically at the computer boot), 5 configuration files are loaded:
- /etc/profile: it contains the global settings for all the command lines available in the operating system.
- /etc/bashrc: it contains global settings for the bash shell.
- ~/.bash_profile: it contains the personal settings for each user in the bash.
- ~/.bashrc: further personal settings per each user, among which the boot and login scripts.
- ~/.bash_logout: logout procedure per each user.
Our first script
A script is a file containing a series of commands for the bash interpreter, organized for executing complex operations.
A script begins usually with a line containing:
and has a .sh extension. It can be executed by writing:
and contains three elements:
- Comments: realized by writing a hash (#) at the beginning of the line.
- Operating system commands: for example grep, cat, etc.
- Shell commands: constructs such as if, while, etc.
No comment present!
Write a comment
You can write here a comment to the article you've just read. Smiles, links and images are not allowed. The maximum comment length is 4000 characters. Please be polite, all the offensive messages will be deleted.