Write a script to learn command line argument
Definition : Write a script that behaves both in interactive and non-interactive mode. When no arguments are supplied, it picks up each C program from current directory and lists the first 10 lines. It then prompts for deletion of the file. If the user supplies arguments with the script, then it works on those files only.
File Name : ex26.sh
flag=1
if
[ $# -ne 0 ]
then
# if user provide arguments
echo $* >temp
flag=1
else
# if user not provide arguments
ans=`ls *.c`
if [ "" ==
"$ans" ]
then
echo "There are no
c file"
flag=0
else
ls *.c>temp
flag=1
fi
fi
if
[ $flag -eq 1 ]
then
for filename in `cat temp`
do
if [ -f $filename ]
then
echo "_______________
$filename _______________"
sed -n -e
"1,10 p" $filename
rm -i
$filename
fi
done
rm
temp
fi
Subscribe to:
Post Comments (Atom)
Subjects
- WordPress
- Mobile Computing-4649303 Practical Solution
- Android Programming New Syllabus Theory
- PHP LAMP Question Bank
- PHP LAMP Theory
- Step by Step Android Example
- Android Practical
- Android Theory
- Android Question Bank
- Networking FON Practical
- Networking FON Theory
- OS Practical
- OS Theory
- HTML
- JavaScript
- J2EE WTAD Theory
- J2EE WTAD Question Bank
- J2EE WTAD Quick Guide
- J2EE WTAD GTU Papers
- J2EE WTAD Practical
- Python
- JAVA Theory
- JAVA Practical
- MIS
Categories
- Android (55)
- c (11)
- Configure Tomcat7 (2)
- CSS (3)
- Decryption (16)
- Difference (1)
- Encryption (16)
- Error Detection and Correction Techniques (3)
- FON (27)
- Framing Technic (2)
- install Tomcat (2)
- J2EE (29)
- JAVA (13)
- JavaScript (19)
- linux (8)
- OS (17)
- PHP (11)
- Protocol (3)
- SERVER SOCKET PROGRAMING (7)
- Servlet (13)
- shell script (33)
- unix (22)
- WTAD (34)
Blog Archive
-
▼
2012
(79)
-
▼
November
(15)
- unix grep command
- Write a script to learn command line argument
- Write a script to display the last modified file
- Write a script to display all lines of a file in a...
- Write a script to display all words of a file in a...
- Write a script to check whether a given number is ...
- Write a script to check whether a given string is ...
- Write a shell script to mathematics calculation
- Write a shell script to Perform Following String O...
- Write a Shell Script for Simple Database Managemen...
- Write a shell script to check whether the named us...
- Write a script which reads a text file and output ...
- Write a script to make following file and director...
- Write a shell script to add the statement #include...
- Write a script to implement the following commands...
-
▼
November
(15)
Total Pageviews
© BipinRupadiya.com. Powered by Blogger.
0 comments:
Post a Comment