Skip to content

Commit 6783b8b

Browse files
committed
shell-scripting linux acad course first unit
1 parent 8a66503 commit 6783b8b

File tree

1 file changed

+79
-0
lines changed
  • linux_training_academy/shell_scripting_sccuintly

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#! /bin/bash -x
2+
#echo 'Shell Scripting is Fun!'
3+
4+
#var='Shell Scripting is Fun!'
5+
#echo "$var"
6+
7+
#hname=$(hostname)
8+
#echo "This script is running on ${hname}."
9+
10+
#######################################################
11+
12+
#FILEPATH="/etc/shadow"
13+
#if [ -f "$FILEPATH" ]; then
14+
# echo "Shadow passwords are enabled."
15+
# if [ -w "$FILEPATH" ]; then
16+
# echo "You have permissions to edit /etc/shadow."
17+
# else
18+
# echo "You do NOT have permissions to edit /etc/shadow."
19+
# fi
20+
#fi
21+
22+
#######################################################
23+
24+
#text=( man bear pig dog cat )
25+
#for i in "${text[@]}"
26+
#do
27+
# echo "$i"
28+
#done
29+
30+
#for i in man bear pig dog cat
31+
#do
32+
# echo $i
33+
#done
34+
#######################################################
35+
36+
#read -p "Enter a file or directory path: " filename
37+
#if [ -f "$filename" ]; then
38+
# echo "Regular File."
39+
#elif [ -d "$filename" ]; then
40+
# echo "A Directory"
41+
#else
42+
# echo "Other type of file."
43+
#fi
44+
45+
#######################################################
46+
47+
#if [ $# -ne 1 ]; then
48+
# echo "Expect only one argument as path to a file/dir."
49+
# exit 1
50+
#fi
51+
52+
#filename="$1"
53+
#if [ -f "$filename" ]; then
54+
# echo "Regular File."
55+
#elif [ -d "$filename" ]; then
56+
# echo "A Directory"
57+
#else
58+
# echo "Other type of file."
59+
#fi
60+
61+
#######################################################
62+
63+
if [ $# -eq 0 ]; then
64+
echo "Expect atleast one argument as path to a file/dir."
65+
exit 1
66+
fi
67+
68+
for filename in $@
69+
do
70+
if [ -f "$filename" ]; then
71+
echo "Regular File."
72+
elif [ -d "$filename" ]; then
73+
echo "A Directory"
74+
else
75+
echo "Other type of file."
76+
fi
77+
done
78+
79+
#######################################################

0 commit comments

Comments
 (0)