Skip to content

Latest commit

 

History

History
32 lines (29 loc) · 764 Bytes

bash_notes.md

File metadata and controls

32 lines (29 loc) · 764 Bytes

BASH SCRIPT

PARAMETERS

$0 name of the script (path included)<br> $1 First parameter Example:
touch parameters.sh
chmod 755 parameters.sh (All permision for user, read and execute permission for the rest )
Script parameters.sh
#!/bin/bash/
# First parameter is assigned to variable USER_NAME
USER_NAME=$1
echo Hello $USER_NAME
echo $(date)
echo $(pwd)
# If the program execute sucessfully returns 0
exit 0
Usage: ./parameters.sh Peter
output: Hello Peter--date--current path

IF-ELSE statement

if [ cond1 ]
then
echo 'message1'
elif[ cond2 ]
then
echo 'message2'
else
echo 'message2'
fi

WHILE