Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,633 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,056 people online right now. Registration is fast and FREE... Join Now!




C Shell Script

 
Reply to this topicStart new topic

C Shell Script

The_Lone_Wolf
post 17 Aug, 2005 - 03:44 AM
Post #1


D.I.C Head

**
Joined: 14 Feb, 2005
Posts: 52



Thanked 1 times
My Contributions


Hi back again this time needing help on shell scripts. I dunno if this is the right place to post this or if this is covered at all but i got a question to do with shell scripts and need some help.

This is the question

1) check that an argument was entered on the command line and that it is the name
of a directory file

2) if no argument was entered on the command line or the argument entered is not
the name of a directory file, then an error message should be output and the script
terminated

3) count the number of files (including files in sub-directories) which has only user
read, write and execute permissions and output relevant statements to tell the user
the number of files in this directory and its sub-directories that satisfy the above
criteria

This is what i have done so far:

#!/bin/csh
if ("$1" == "" ) then
echo a directory file name argument required
exit
endif
if (! (-d $1) ) then
echo $1 should be a directory
exit

I hope that what i have done covers point one but i dont know how to include the error message for point 2 nor the counting of files for point3 . I am pretty sure thought that for point 3 it uses the foreach statement.

Any Help.
User is offlineProfile CardPM

Go to the top of the page

The_Lone_Wolf
post 17 Aug, 2005 - 10:24 AM
Post #2


D.I.C Head

**
Joined: 14 Feb, 2005
Posts: 52



Thanked 1 times
My Contributions


Well does anyone know?
User is offlineProfile CardPM

Go to the top of the page

Nova Dragoon
post 17 Aug, 2005 - 10:27 AM
Post #3


The Innocent Shall Suffer, Big Time

Group Icon
Joined: 16 Aug, 2001
Posts: 6,128



Thanked 4 times

Dream Kudos: 515

Expert In: Python, Linux

My Contributions


I've never used csh. but I have used bash.

if -d is check for directory then that portion logically looks correct.

for point 3, look into the "find" command, it has a flag to search for file types (dir, file, etc) and a bunch more
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 04:01AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month