?
Solved

Bourne Shell

Posted on 1998-12-14
2
Medium Priority
?
363 Views
Last Modified: 2013-12-26
my question is

create a shell script called DELSTAR which will accept input, and then check if the input is a directory file and is readable and writable. If so, then all the ordinary files under the diirectory should be listed out one by one.For each ordinary file that is writeable, the user should be ask if the file is to be deleted or not. If yes, theb the deletion should be done, else the next file processed.
At the end of the execution, the script should display the following message:
_________ordinary files deleted from the directory
_________ordinary files remaining in the directory

(From eugene)
age:18(IT Student)
0
Comment
Question by:sumbat31
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 800 total points
ID: 1294836
#! /bin/sh
#
# check for symbolic links may be different on your OS
#
if [ $# -lt 0 ]; then
   echo 'schoolworks are usually done yourself :-)'
   exit 1;
fi
dir=$1
cnt=0
rem=0
if [ -d $dir -a -r $dir -a -w $dir ]; then
   cd $dir
   for f in `ls`; do
        if [ -L $f ]; then
            continue
        fi
        if [ -f $f ]; then
            cnt=`expr $cnt + 1`
            rm -i $f
        fi
   done
   for f in `ls`; do
        if [ -L $f ]; then
            continue
        fi
        if [ -f $f ]; then
            rem=`expr $rem + 1`
        fi
   done
   del=`expr $cnt - $ rem`
   echo $cnt ordinary files deleted
   echo ordinary files remaining $rem
else
   exit 2;
fi


0
 

Author Comment

by:sumbat31
ID: 1294837
You did a fine job
0

Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question