Skip to content

Commit 7f56c55

Browse files
committed
New files are addedclear!
1 parent c03542b commit 7f56c55

File tree

5 files changed

+74
-0
lines changed

5 files changed

+74
-0
lines changed

ScenariosFullChapter2/Scenario10.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
if [ $# -eq 0 ]
3+
then
4+
echo "No inputs send via command line!! Exiting" >&2; exit 1;
5+
fi
6+
path=$1
7+
path1="/home/ubuntu/Desktop/Automation-using-Shell-Scripts/ScenariosFullChapter2/"
8+
if [ -d $path ]
9+
then
10+
rm -r $path
11+
echo `date +%F` >> $path1/del.log
12+
echo "$whoami" >> $path1/del.log
13+
echo "$path" >> $path1/del.log
14+
fi
15+
if [ -f $path ]
16+
then
17+
rm $path
18+
echo `date +%F` >> $path1/del.log
19+
echo "$USERs" >> $path1/del.log
20+
echo "$path" >> $path1/del.log
21+
fi

ScenariosFullChapter2/Scenario1314.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
read -p "Enter the path of the folder to Encrypt: " f
3+
gpg -c $f
4+
echo "Folder encrypted!!"
5+
read -p "Do you want to decrypt now? " res
6+
case $res in
7+
y|Y|yes|YES) gpg -d $f.gpg ;;
8+
*) echo "Folder is still encrypted!!!" ;;
9+
esac
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
read var
3+
if [ -z $var ]
4+
then
5+
read var
6+
fi
7+
compressed="$(echo $var | sed -e 's/[^[:alnum:]]'//g)"
8+
if [ $compressed != "$var" ]
9+
then
10+
echo "Input is not alphanumeric"
11+
else
12+
echo "Input is alphanumeric"
13+
fi
14+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
read -p "Command to check which users have used: " var
3+
if [ $whoami == "root" ]
4+
then
5+
echo " "
6+
else
7+
echo "Run as root!!"
8+
exit 1
9+
fi
10+
grep -n $var /home/*/.bash_history >> /home/ubuntu/Desktop/Automation-using-Shell-Scripts/file.txt
11+
cat /home/ubuntu/Desktop/Automation-using-Shell-Scripts/file.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
path="$1"
3+
a="$#"
4+
lastarg="${!a}"
5+
read -p "Search element: " ser
6+
read -p "Replace element: " rep
7+
if [ -d "$lastarg" ]
8+
then
9+
add=*.txt
10+
else
11+
if [ -f "$lastarg" ]
12+
then
13+
add="$lastarg"
14+
else
15+
echo "Invalid path"
16+
fi
17+
fi
18+
sed -i -e -w 's/'"$ser"'/'"$rep"'/g' $add
19+

0 commit comments

Comments
 (0)