-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremovePackages.sh
executable file
·47 lines (42 loc) · 977 Bytes
/
removePackages.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
packagesFile="$HOME/.packagesFile"
createFile() {
if [ -f $packagesFile ]; then
filesLines
echo "Packages File exist! and has $count packages"
else
echo "Packages File dind't exist."
echo "creating..."
touch $HOME/.packagesFile
echo "Packages File created!"
echo "To remove packages, first you need to add packages..."
fi
}
filesLines() {
count=0
while IFS= read -r line; do
count=$((count + 1))
done <$packagesFile
}
remove() {
packageline=0
find=$false
while IFS= read -r line; do
packageline=$((packageline + 1))
if [ "$package" == "$line" ]; then
echo "Package found on line $packageline!"
sed -i "/$package/d" "$packagesFile"
find=$true
fi
done <$packagesFile
if [ $find ]; then
echo "Dint find the package :( "
fi
}
createFile
echo "Type the name of package you wanna remove"
read package
remove
filesLines
echo "Packages file are Update, you have $count packages!"
echo "The peackage you remove is $package"