Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

shell program examples, Assignments of Programming Languages

4 semester shell examples ..contains example of shell programs

Typology: Assignments

2023/2024

Uploaded on 06/21/2025

dr-shruthi
dr-shruthi 🇮🇳

1 document

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Example 1
#!/bin/sh
echo "What is your name?"
read PERSON
echo "Hello, $PERSON"
output
$./test.sh
What is your name?
Zara Ali
Hello, Zara Ali
$
Example 2
$cat my_script.sh
clear echo "This is my first shell script."
echo "Today’s date is `date | cut –d " " –f 1–3`"
echo "Now the time is `date | cut –d " "–f 4`"
echo "GOOD LUCK" $
output
$sh my_script.sh
This is my first shell script.
Today's date is Tue Nov 26
Now the time is 13:05:57
GOOD LUCK $
pf3

Partial preview of the text

Download shell program examples and more Assignments Programming Languages in PDF only on Docsity!

#!/bin/sh

echo "What is your name?"

read PERSON

echo "Hello, $PERSON"

output

$./test.sh

What is your name?

Zara Ali

Hello, Zara Ali

Example 2

$cat my_script.sh clear echo "This is my first shell script." echo "Today’s date is date | cut –d " " –f 1–3" echo "Now the time is date | cut –d " "–f 4" echo "GOOD LUCK" $ output $sh my_script.sh This is my first shell script. Today's date is Tue Nov 26 Now the time is 13:05: GOOD LUCK $

$cat readname.sh echo what is your name ? read name echo The name is $name. output : $chmod u+× readname.sh $readname.sh what is your name? murthy Example 4 $cat example echo Input a value for x read x echo the value of x is $x readonly x x=expr $x + 1 echo The value of x now is $x output : $sh example Input a value for x The value of x is 4 example: line 5: x: readonly variable