Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions compare.sh
Original file line number Diff line number Diff line change
@@ -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

15 changes: 15 additions & 0 deletions cpu_usage.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions file1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
echo "Hello,World!"
echo "Hi"