HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Programming/Scripts (http://www.howtoforge.com/forums/forumdisplay.php?f=7)
-   -   question in shell script (http://www.howtoforge.com/forums/showthread.php?t=53953)

abood1190 29th August 2011 05:52

question in shell script
 
Hell guys,
I need a little help to solve this question

Write a Bourne shell script which:
Has one command line argument.
If the command line argument is a directory then the script should output the number of files in the directory.
If the command line argument is an ordinary file then the script should output whether or not the file has execute permission for the file owner.
If the command line argument is neither a file or directory then the script should output an appropriate error message.
If no command line argument is supplied then the script should output an appropriate error message.

till 29th August 2011 13:04

You might want to take a look here first:

http://tldp.org/LDP/abs/html/

If you wrote your execise script then and some parts of it wont work and you are unable to find the problem yourself, then post your script.

abood1190 1st September 2011 01:39

Quote:

Originally Posted by till (Post 262457)
You might want to take a look here first:

http://tldp.org/LDP/abs/html/

If you wrote your execise script then and some parts of it wont work and you are unable to find the problem yourself, then post your script.

this is my code
Code:

#!/bin/sh

echo " Command line argument is :" $1

if [ -d $1 ]
then
echo " The number of files in the directory is ` ls -l | wc -l` "
else
echo " It is not a dirctory "
fi

if [ -f $1 ]
then
echo " The execute permission for the file owner is ` ls -l $1`"
else
echo " There is no execute permission "
fi

the code might be wrong !!
the time for submission is up !
Thank you

id10t 2nd September 2011 16:01

Smells like homework anyway...


All times are GMT +2. The time now is 05:31.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.