

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


#!/bin/bash echo -n "Enter directory name ->" read dir if [ -d "$dir" ] then echo "Directory exists" else mkdir $dir echo "Directory created" fi Question 1 What does this script do? If you run it twice giving the same directory name both times, what is the output to the screen on the second time through? This script is used to create a directory if it does not exist. If you run it twice giving the same directory name both times, the output to the screen on the second time is Directory exists Question 2 What is “fi”?
Question 3 What is the purpose of the very first line in the above script?
#!/bin/bash echo ‘Please enter your name’ read name echo “My Name is $name” Question 4 What is the difference between single and double quotes in bash scripting? When the $name is enclosed within single quotes, then the text inside is retained and the value does not get displayed. The $name does not get interpolated. But when it is closed within double quotes, then the $name is evaluated, and the value is showed up.
Question 5 What does the $ signify in scripting? It is a special variable in shell that reads the exit status of the last command executed. Question 6
using System; namespace CshapeExample { class Program { static void Main(string[] args) { Console.WriteLine("Enter a number:"); int num = Console.ReadLine(); if(num>10){ Console.WriteLine(“Your number is greater than 10”); } if(num=10){ Console.WriteLine(“Your number is equal to 10”); } else{ Console.WriteLine(“Your number is lesser than 10”);} } } }