Write a program called myrm that takes as arguments the names of files to be removed. If the global variable MAXFILES is set, take it as the maximum number of files to remove without question. If the variable is not set, use 10 as the maximum. If the number of files to be removed exceeds this count, ask the user for confirmation before removing the files.

$ ls | we -l
25
$ myrm * Remove them all
Remove 25 files (y/n)? n
files not removed
$ MAXFILES=l00 myrm *
$ ls
$ All files removed
If MAXFILES is set to zero, the check should be suppressed.


# Set maxfiles to environmental variable MAXFILES, if set, or 10

maxfiles=${MAXFILES:-10}

if [ $maxfiles -eq 0 ] ; then
maxfiles=9999 # skip test if maxfiles = 0
fi

# how many files did the user specify they want removed?

files=$( ls $@ | wc -l )

if [ $files -gt $maxfiles ] ; then
echo "Remove $files files (y/n)? \c" ; read answer
if [ "$answer" != "y" ] ; then
echo "Remove cancelled."
exit 1
fi
fi

rm $@

Computer Science & Information Technology

You might also like to view...

An associative mapping __________.

a) stores the entire page table in content-addressed associative memory b) provides better performance than direct mapping c) is too expensive to implement d) all of the above

Computer Science & Information Technology

Where is IPv6 running on a device if the device is running at "wire speed?"

A. in an ASIC B. in software C. in flash memory D. in the CPU

Computer Science & Information Technology

One way to create a form in Access, is to use the ________ which can be used to select multiple tables and specific fields for the form

A) control grid B) Input Mask Wizard C) Form Wizard D) Navigation Pane

Computer Science & Information Technology

A theme can be applied to a report in either Layout or Report views

Indicate whether the statement is true or false

Computer Science & Information Technology