diff --git a/compare.sh b/compare.sh new file mode 100755 index 0000000..652eb54 --- /dev/null +++ b/compare.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# taking three inputs from the user + +echo "Enter the first number:" +read num1 +echo "Enter the second number:" +read num2 +echo "Enter the third number:" +read num3 + +#adding the first and second number +sum=$((num1 + num2)) + +# checking if the sum is equal to the third number +if [ $sum -eq $num3 ]; then + echo " the sum of $num1 and $num2 is equal to $num3." +else + echo "the sum of $num1 and $num2 is not equal to $num3." +fi + diff --git a/cpu_usage.sh b/cpu_usage.sh new file mode 100755 index 0000000..91d1b43 --- /dev/null +++ b/cpu_usage.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +FILE="/home/cpu_file1.txt" + +if [ -f "$FILE" ]; then + sudo rm -f "$FILE" +else + sudo touch "$FILE" + CPU_USAGE=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1}') + + echo "This is the CPU usage $CPU_USAGE " + + + top >> $FILE +fi diff --git a/file1.sh b/file1.sh new file mode 100755 index 0000000..0ce4757 --- /dev/null +++ b/file1.sh @@ -0,0 +1,4 @@ +#!/bin/bash +echo "Hello,World!" +echo "Hi" +