Linux_ShellScripting-1
Linux_ShellScripting-1
count=1
num=5
Output-
Number is 1
Number is 2
Number is 3
My task is Coding
My task is Browsing
My task is Calling
My task is Sleeping
Output-
Numbers are 1
Numbers are 2
Numbers are 3
Numbers are 4
Numbers are 5
If-else Program-
#!/bin/bash
echo Hi User!
echo What is your name?
read name
echo Hey $name, Welcome to Online Portal for
Elections Status...
echo Please enter your age:
read age
if [ $age -ge 18 ]
then
echo You can vote!
else
echo Sorry $name, You cannot vote!
Fi
Output-
Hi User!
What is your name?
Garvit
Hey Garvit, Welcome to Online Portal for Elections
Status...
Please enter your age:
19
You can vote!
Variables Program-
#!/bin/bash
name=Garvit
age=19
echo My name is $name and my age is $age
Output-
My name is Garvit and my age is 19
Switch-case Program-
#!/bin/bash
case $choice in
1)date;;
2)ls -ltr;;
3)pwd;;
*)echo Invalid choice detected....Exitting the
program..Bye!!
esac
Output-
If we enter the choice – 1
Hi, Welcome to E-Learning Platform for Linux
Enter your name:
Garvit
Welcome Garvit, Please choose any option from
below:
1
Mon Feb 27 10:08:24 IST 2023
2
total 0
-rwxr--r-- 1 chugh09 chugh09 30 Feb 25 22:49 helloWorld.sh
-rwxr--r-- 1 chugh09 chugh09 73 Feb 25 22:54 variables.sh
-rwxr--r-- 1 chugh09 chugh09 94 Feb 25 22:57 linux_commands_printing.sh
-rwxr--r-- 1 chugh09 chugh09 169 Feb 25 23:01 user_input.sh
-rwxr--r-- 1 chugh09 chugh09 253 Feb 25 23:45 if_else.sh
-rwxr--r-- 1 chugh09 chugh09 407 Feb 25 23:58 cases_script.sh
-rwxr--r-- 1 chugh09 chugh09 138 Feb 26 00:38 for_loop.sh
-rwxr--r-- 1 chugh09 chugh09 100 Feb 26 00:48 while_loop.sh
-rw-r--r-- 1 chugh09 chugh09 46 Feb 26 01:02 Friends
-rwxr--r-- 1 chugh09 chugh09 125 Feb 26 01:04 file_iteration.sh
3
/home/chugh09/Scripts`
4
Invalid choice detected....Exitting the
program..Bye!!