Skip to content

Commit 430f35b

Browse files
committed
format scrpit
1 parent 9039118 commit 430f35b

33 files changed

Lines changed: 469 additions & 499 deletions

scripts/Addition.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ echo .Enter the Second Number: .
55
read b
66
x=$(expr "$a" + "$b")
77
echo $a + $b = $x
8-

scripts/Armstrong.sh

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
#!/bin/bash
2-
echo "Enter A Number"
3-
read n
4-
arm=0
5-
temp=$n
6-
while [ $n -ne 0 ]
7-
do
8-
r=$(expr $n % 10)
9-
arm=$(expr $arm + $r \* $r \* $r)
10-
n=$(expr $n / 10)
11-
done
12-
echo $arm
13-
if [ $arm -eq $temp ]
14-
then
15-
echo "Armstrong"
16-
else
17-
echo "Not Armstrong"
18-
fi
19-
20-
1+
#!/bin/bash
2+
echo "Enter A Number"
3+
read n
4+
arm=0
5+
temp=$n
6+
while [ $n -ne 0 ]; do
7+
r=$(expr $n % 10)
8+
arm=$(expr $arm + $r \* $r \* $r)
9+
n=$(expr $n / 10)
10+
done
11+
echo $arm
12+
if [ $arm -eq $temp ]; then
13+
echo "Armstrong"
14+
else
15+
echo "Not Armstrong"
16+
fi

scripts/Binary2Decimal.sh

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
1-
#!/bin/bash
2-
echo "Enter a number :"
3-
read Binary
4-
if [ $Binary -eq 0 ]
5-
then
6-
echo "Enter a valid number "
7-
else
8-
while [ $Binary -ne 0 ]
9-
do
10-
Bnumber=$Binary
11-
Decimal=0
12-
power=1
13-
while [ $Binary -ne 0 ]
14-
do
15-
rem=$(expr $Binary % 10 )
16-
Decimal=$((Decimal+(rem*power)))
17-
power=$((power*2))
18-
Binary=$(expr $Binary / 10)
19-
done
20-
echo " $Decimal"
21-
done
22-
fi
1+
#!/bin/bash
2+
echo "Enter a number :"
3+
read Binary
4+
if [ $Binary -eq 0 ]; then
5+
echo "Enter a valid number "
6+
else
7+
while [ $Binary -ne 0 ]; do
8+
Bnumber=$Binary
9+
Decimal=0
10+
power=1
11+
while [ $Binary -ne 0 ]; do
12+
rem=$(expr $Binary % 10)
13+
Decimal=$((Decimal + (rem * power)))
14+
power=$((power * 2))
15+
Binary=$(expr $Binary / 10)
16+
done
17+
echo " $Decimal"
18+
done
19+
fi

scripts/Colorfull.sh

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
11
#!/bin/bash
22

3-
clear
3+
clear
44
echo -e "\033[1m Hello World"
5-
# bold effect
5+
# bold effect
66
echo -e "\033[5m Blink"
7-
# blink effect
7+
# blink effect
88
echo -e "\033[0m Hello World"
9-
# back to noraml
9+
# back to noraml
1010

1111
echo -e "\033[31m Hello World"
12-
# Red color
12+
# Red color
1313
echo -e "\033[32m Hello World"
14-
# Green color
14+
# Green color
1515
echo -e "\033[33m Hello World"
16-
# See remaing on screen
16+
# See remaing on screen
1717
echo -e "\033[34m Hello World"
1818
echo -e "\033[35m Hello World"
1919
echo -e "\033[36m Hello World"
2020

2121
echo -e -n "\033[0m"
22-
# back to noraml
22+
# back to noraml
2323
echo -e "\033[41m Hello World"
2424
echo -e "\033[42m Hello World"
2525
echo -e "\033[43m Hello World"
2626
echo -e "\033[44m Hello World"
2727
echo -e "\033[45m Hello World"
2828
echo -e "\033[46m Hello World"
2929

30-
3130
echo -e "\033[0m Hello World"
32-

scripts/Decimal2Binary.sh

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
1-
#!/bin/bash
2-
3-
for ((i=32;i>=0;i--)); do
4-
r=$(( 2**$i))
5-
Probablity+=( $r )
6-
done
7-
8-
[[ $# -eq 0 ]] && { echo -e "Usage \n \t $0 numbers"; exit 1; }
9-
10-
echo -en "Decimal\t\tBinary\n"
11-
for input_int in $@; do
12-
s=0
13-
test ${#input_int} -gt 11 && { echo "Support Upto 10 Digit number :: skiping \"$input_int\""; continue; }
14-
15-
printf "%-10s\t" "$input_int"
16-
17-
for n in ${Probablity[@]}; do
18-
19-
if [[ $input_int -lt ${n} ]]; then
20-
[[ $s = 1 ]] && printf "%d" 0
21-
else
22-
printf "%d" 1 ; s=1
23-
input_int=$(( $input_int - ${n} ))
24-
fi
25-
done
26-
echo -e
27-
done
1+
#!/bin/bash
2+
3+
for ((i = 32; i >= 0; i--)); do
4+
r=$((2 ** $i))
5+
Probablity+=($r)
6+
done
7+
8+
[[ $# -eq 0 ]] && {
9+
echo -e "Usage \n \t $0 numbers"
10+
exit 1
11+
}
12+
13+
echo -en "Decimal\t\tBinary\n"
14+
for input_int in $@; do
15+
s=0
16+
test ${#input_int} -gt 11 && {
17+
echo "Support Upto 10 Digit number :: skiping \"$input_int\""
18+
continue
19+
}
20+
21+
printf "%-10s\t" "$input_int"
22+
23+
for n in ${Probablity[@]}; do
24+
25+
if [[ $input_int -lt ${n} ]]; then
26+
[[ $s == 1 ]] && printf "%d" 0
27+
else
28+
printf "%d" 1
29+
s=1
30+
input_int=$(($input_int - ${n}))
31+
fi
32+
done
33+
echo -e
34+
done

scripts/Disk-Space.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
MAX=95
22
EMAIL=server@127.0.0.1
33
PART=sda1
4-
5-
USE=`df -h |grep $PART | awk '{ print $5 }' | cut -d'%' -f1`
4+
5+
USE=$(df -h | grep $PART | awk '{ print $5 }' | cut -d'%' -f1)
66
if [ $USE -gt $MAX ]; then
7-
echo "Percent used: $USE" | mail -s "Running out of disk space" $EMAIL
7+
echo "Percent used: $USE" | mail -s "Running out of disk space" $EMAIL
88
fi

scripts/Division.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/bin/bash
2-
echo .Enter the First Number: .
3-
read a
4-
echo .Enter the Second Number: .
5-
read b
6-
echo "$a / $b = $(expr $a / $b)"
7-
8-
2+
echo .Enter the First Number: .
3+
read a
4+
echo .Enter the Second Number: .
5+
read b
6+
echo "$a / $b = $(expr $a / $b)"

scripts/Encrypt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
echo "Welcome, I am ready to encrypt a file/folder for you"
44
echo "currently I have a limitation, Place me to the same folder, where a file to be encrypted is present"
55
echo "Enter the Exact File Name with extension"
6-
read file;
6+
read file
77
# decryption command
88
# gpg -d filename.gpg > filename
99
gpg -c $file

scripts/EvenOdd.sh

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
#!/bin/bash
2-
echo "Enter The Number"
3-
read n
4-
num=$(expr $n % 2)
5-
if [ $num -eq 0 ]
6-
then
7-
echo "is a Even Number"
8-
else
9-
echo "is a Odd Number"
2+
echo "Enter The Number"
3+
read n
4+
num=$(expr $n % 2)
5+
if [ $num -eq 0 ]; then
6+
echo "is a Even Number"
7+
else
8+
echo "is a Odd Number"
109
fi
11-
12-

scripts/Factorial.sh

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
#!/bin/bash
2-
echo "Enter The Number"
3-
read a
4-
fact=1
5-
while [ $a -ne 0 ]
6-
do
7-
fact=$(expr $fact \* $a)
8-
a=$(expr $a - 1)
9-
done
1+
#!/bin/bash
2+
echo "Enter The Number"
3+
read a
4+
fact=1
5+
while [ $a -ne 0 ]; do
6+
fact=$(expr $fact \* $a)
7+
a=$(expr $a - 1)
8+
done
109
echo $fact
11-
12-

0 commit comments

Comments
 (0)