Shell_Script
Shell_Script
->Code:
#!/bin/bash
Output:
-> Code:
#!/bin/bash
read -r num1
read -r num2
sum=$((num1 + num2))
Output:
-> Code:
#!/bin/bash
echo "Enter a number: "
read number
if (( number % 2 == 0 ))
then
else
fi
Output:
-> Code:
#!/bin/bash
for i in {1..10}; do
echo $i
done
Output:
5. Check if a File Exists.
-> Code:
#!/bin/bash
read filename
if [ -f "$filename" ]; then
else
Fi
Output:
->Code
#!/bin/bash
read num1
echo "Enter the second number: "
read num2
read num3
then
then
else
fi
Output:
->Code
#!/bin/bash
Output:
8. Create a Directory.
->Code
#!/bin/bash
directory_name="Pradipta_3008"
mkdir "$directory_name"
if [ -d "$directory_name" ]; then
else
fi
Output:
->Code
#!/bin/bash
read num
original_num=$num
reverse=0
last_digit=$((num % 10))
reverse=$((reverse * 10 + last_digit))
num=$((num / 10))
done
else
fi
Output:
->Code
#!/bin/bash
read num
factorial=1
else
do
factorial=$((factorial * i))
done
fi
Output: