exercise2 and exercise3, add functions folder
This commit is contained in:
19
exit_return_codes/exercise2.sh
Executable file
19
exit_return_codes/exercise2.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
FD_NAME=$1
|
||||
|
||||
if [ -f $FD_NAME ]
|
||||
then
|
||||
echo "${FD_NAME} is a regular file."
|
||||
exit 0
|
||||
elif [ -d $FD_NAME ]
|
||||
then
|
||||
echo "${FD_NAME} is a regular directory."
|
||||
exit 1
|
||||
else
|
||||
echo "${FD_NAME} is NOT a regular file or directory."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Exit with an explicit exit status.
|
||||
exit 0
|
||||
18
exit_return_codes/exercise3.sh
Executable file
18
exit_return_codes/exercise3.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# <Replace with the purpose or description of of this shell script.>
|
||||
#
|
||||
|
||||
cat /etc/shadow
|
||||
|
||||
if [ "$?" -ne "0" ]
|
||||
then
|
||||
echo "Command failed"
|
||||
exit 1
|
||||
else
|
||||
echo "Command succeeded"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Exit with an explicit exit status.
|
||||
exit 0
|
||||
Reference in New Issue
Block a user