This is not the document you are looking for? Use the search form below to find more!

Report home > Computer / Internet

Linux Shell Programming

4.50 (2 votes)
Document Description
This is about Shell programming in Linux platform
File Details
  • Added: October, 07th 2010
  • Reads: 854
  • Downloads: 44
  • File size: 8.80kb
  • Pages: 2
  • Tags: computer, linux, programming
  • content preview
Submitter
  • Name: Ranjan
Embed Code:

Add New Comment




Related Documents

Unix Shell Programming 1st internal

by: mcaacharya2010, 4 pages

This documents contains 11 Unix Shell Programming that is likely to be asked in 1st internal exam for 10MCA. By Uploaded By Sumit...!

GNU/Linux Application Programming (Programming Series) by M. Tim Jones

by: almira, 2 pages

GNU/Linux Application Programming (Programming Series) by M. Tim Jones Great Reference If You Program For The Linux Platform GNU/Linux is the Swiss army ...

A-Linux-Shell-Environment-Also-Takes-Commands-That56

by: suraw1961181, 8 pages

this: cat file3 >folden The file named folden contains the contents of file3

Home Networking In Linux Iptables Firewall, Routing, Wireless, and More

by: manualzon, 44 pages

home networking tutorial ebook with linux contains various info on firewall, Iptables, Routing, Wireless etc

Socket Programming In Python

by: reijo, 25 pages

Socket Programming In Python

Asynchronous Io Programming

by: rita, 35 pages

Asynchronous Io Programming

Socket Programming Tutorial

by: ville, 35 pages

Socket Programming Jignesh Patel Palanivel Rathinam connecting processes Overview Introduction to Sockets A generic Client-Server application ...

linux textbook

by: himakar786, 891 pages

happy to enjoy this book

C Programming Tutorial

by: desantis, 410 pages

This book is a tutorial. Its aim is to teach C to a beginner, but with enough of the details so as not be outgrown as the years go by. It presumes that you have some previous acquittance with ...

Advanced programming with lcc-win32

by: desantis, 62 pages

C programming with lcc-win32. Jacob Navia and Friedrich Dominicus. This document is part of the lcc-win32 documentation.

Content Preview
1. Write A shell script that takes a command –line argument and reports on whether it is directry ,a file,or something else
Sol:

echo "Enter a file name:"
read f
if [ -f $f ]
then

echo "File"
elif [ -d $f ]
then

echo "Directory"
else

echo "Not"
fi

2. Write a shell script that accepts a file name starting and ending line numbers as arguments and displays all the lines between the given
line numbers
Sol:
$ awk ‘NR<2 || NR> 4 {print $0}’ 5 lines.dat
I/P:
line1
line2
line3
line4
line5
O/P: line1

line5
3. Write a shell script that computes the gross salary of a employee according to the following
1) if basic salary is <1500 then HRA 10% of the basic and DA =90% of the basic
2) if basic salary is >1500 then HRA 500 and DA =98% of the basic
The basic salary is entered interactively through the key board
echo " Enter the Salary "
read sal
if [ $sal -lt 1500 ]
then
da=$(($sal*90/100 ))
hra=$(($sal*10/100))
gsal=$(($sal+$hra+$da))
elif [ $sal -ge 1500 ]
then
hra=500
da=$(($sal*98/100))
gsal=$(($sal+$hra+$da))
fi
echo "Gross Salary is :"$gsal
4. Write a shell script that accepts two integers as its arguments and computes the value of first number added with the second number
a=$1
b=$2
c=$(($a+$b))
echo$c
5.Write a shell script for printing the following numbers as output.
1
2
3
4
5
6
7
8
9
10
x=0
while [ $x -lt 10 ]
do
echo $x
x=$(($x+1))
done
exercise: write a shell script to print the numbers in the above mentioned way where the user can input the value of x.
6. Write a shell script for printing the following numbers as output.
0
1 0


2 1 0
3 2 1 0
4 3 2 1 0
x=0
while [ $x -lt 4 ]
do
y=$x
while [ $y -ge 0 ]
do
echo $y '\c'
y=$(($y-1))
done
echo
x=$(($x+1)
done
exercise: write a shell program to print the output as above but the user will give the value of x.
exercise: write a shell program to print the following outputs
a. *
**
***
****
b. ****
***
**
*

7. Write a shell script that displays a list of all files in the current directory to which the user has read write and execute permissions
read -p "Enter a directory name : " dn
if [ -d $dn ]; then
printf "\nFiles in the directory $dn are :\n"
for fn in `ls $dn`
do
if [ -d $dn/$fn ]; then
printf "<$fn> Directory "
elif [ -f $dn/$fn ]
then
printf "$fn File "
fi
if [ -r $dn/$fn ]; then
printf " Read"
fi

if [ -w $dn/$fn ];then
printf " Write"
fi

if [ -x $dn/$fn ];then
printf " Execute"
fi
printf "\n"
done
else
printf "\n$dn not exists or not a directory"
fi



Download
Linux Shell Programming

 

 

Your download will begin in a moment.
If it doesn't, click here to try again.

Share Linux Shell Programming to:

Insert your wordpress URL:

example:

http://myblog.wordpress.com/
or
http://myblog.com/

Share Linux Shell Programming as:

From:

To:

Share Linux Shell Programming.

Enter two words as shown below. If you cannot read the words, click the refresh icon.

loading

Share Linux Shell Programming as:

Copy html code above and paste to your web page.

loading