Shell Basics
This Repository is meant for learning and documenting Shell Lessons just like in Just Python
- Create a bash file using standard linux editor
vi
. - Execute the following commands to open a file namely
vi start_with_bash.bash
. - Start with
#!/usr/bin/bash
as the first line. The significane of having this line as the first line tells the OS to invoke the specified shell to execute the commands that follow in the script.#!
is often referred to as a "hash-bang", "she-bang" or "sha-bang". - Add a few lines as below.
- Exit after saving using
:wq
. Change the script execution permissions using the commandchmod u+x start_with_bash.bash
. - Execute the script using the command
./start_with_bash.bash
#!/usr/bin/bash
echo "Printing the script."
The following are the keywords which cannot be used for declaring variables.
read
echo
readonly
set
unset
shift
export
if
then
else
fi
elif
case
esac
break
continue
while
until
for
select
do
done
eval
trap
test
exec
sleep
wait
return
exit
#!/usr/bin/bash
echo "A comment will follow after this line" # Here is the comment
echo "A # here does not begin a comment"
echo A \# here does not begin a comment
echo The # here begins a comment
As in the above scripts, anything after #
is depricated. See the output on executing the above script.
A comment will follow after this line
A # here does not begin a comment
A # here does not begin a comment
The
All relevant resources are available here: resources