What is bash scripting?
Bash script: a plain text that contains a series of commands, which
can be used to write Linux commands in the terminal.
Anything you can run normally on the command line can be put into
a script and it will do exactly the same thing.
Bash scripts an extension of .sh (myscript.sh). However, Linux is an
extensionless system so a script doesn't necessarily have to have this
characteristic in order to work.
How to execute a bash script?
./script → it will execute the script file, as
a new child process within the
to grant permissions, to execute file:
chmod 755 script1 ⇔
(rwxr-xr-x) The file's owner may read, write, and execute the file. All
others may read and execute the file.
#!/bin/bash ⇔ The first line in code, must start with “#!”.
# A sample Bash script ⇔ comment line, not executed.
echo Hello World! ⇔ actual command that could be directly written in the terminal.
To declare a variable:
$a, $A, $a1A.
To initialize a variable
To display the variable and its value
text=" $var Ahmed"