We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8
Practical No:10
Name:Vikram Santosh Nimbalkar
Roll No:66 Code: Positive number: a=10 if [[ $a -ge 0 ]]; then echo "number is positive" fi Code If statement echo "Enter one number" read a if [[ $a -ge 0 ]]; then echo "number is positive" fi If Else Statement echo "Enter one number" read a if [[ $a -ge 0 ]]; then echo "number is positive" else echo "Is negative Number" fi Grater And Large Number echo "Enter two numbers" read a b if [[ $a -gt $b ]]; then echo "a is greater" elif [[ $a -lt $b ]]; then echo "b is greater" else echo "Both numbers are equal" fi Single Decision echo "Enter a number:" read num if [[ $num -gt 0 ]]; then echo "The number is positive." Fi Double Decision echo "Enter a number:" read num if [[ $num -gt 0 ]]; then echo "The number is positive." else echo "The number is not positive." fi Multiple Decision echo "Enter two numbers:" read a b if [[ $a -gt $b ]]; then echo "a is greater." elif [[ $a -lt $b ]]; then echo "b is greater." else echo "Both numbers are equal." Fi Three Number echo "Enter three numbers:" read a b c
if [[ $a -ge $b ]] && [[ $a -ge $c ]]; then
echo "The greatest number is: $a" elif [[ $b -ge $a ]] && [[ $b -ge $c ]]; then echo "The greatest number is: $b" else echo "The greatest number is: $c" fi Exercise 1.Check file Readable read -p "Enter a filename: " filename if [ ! -r "$filename" ]; then echo "File $filename is not readable - skipping." Fi 2.Check Never if [ "$sam.sh" -nt "/etc/passwd" ]; then echo "X is a file which is newer than /etc/passwd" fi