Sponsored Content
Top Forums Shell Programming and Scripting can you think of a better way? Post 15011 by Kelam_Magnus on Friday 8th of February 2002 02:16:14 PM
Old 02-08-2002
Your script looks good.

You need to close the `cat ... statement with another ` .
Also, depending on your Flavor of UNIX, you probably don't need the brackets and semicolons.

In your cat statement you can put the full path of the file that contains the columnar list of the files to be deleted. I would hope that this list shows the full path of each file to be deleted as well.

You can also use the "-i" option if you want to double check the deletion of the file, but it looks like you already want to get rid of all of these files.


Here is my variation of your script. Yours was good, but I like to see a logfile output with errors as well.

The 2> delete.error.log will record any exceptions to your script. That you can look at later. This is good especially for more complicated scripts.


for A in `cat filename`
do
echo $A "is being deleted now" >> delete.log
find . -name $A -exec rm {} \;
echo $A "has been deleted" >> delete.log 2> delete.error.log
done



Smilie
 
DH_CLEAN(1)                                                          Debhelper                                                         DH_CLEAN(1)

NAME
dh_clean - clean up package build directories SYNOPSIS
dh_clean [debhelperoptions] [-k] [-d] [-Xitem] [path...] DESCRIPTION
dh_clean is a debhelper program that is responsible for cleaning up after a package is built. It removes the package build directories, and removes some other files including debian/files, and any detritus left behind by other debhelper commands. It also removes common files that should not appear in a Debian diff: #*# *~ DEADJOE *.orig *.rej *.SUMS TAGS .deps/* *.P *-stamp It does not run "make clean" to clean up after the build process. Use dh_auto_clean(1) to do things like that. dh_clean should be the last debhelper command run in the clean target in debian/rules. FILES
debian/clean Can list other paths to be removed. Note that directories listed in this file must end with a trailing slash. Any content in these directories will be removed as well. OPTIONS
-k, --keep This is deprecated, use dh_prep(1) instead. The option is removed in compat 12. -d, --dirs-only Only clean the package build directories, do not clean up any other files at all. -Xitem --exclude=item Exclude files that contain item anywhere in their filename from being deleted, even if they would normally be deleted. You may use this option multiple times to build up a list of things to exclude. path ... Delete these paths too. Note that directories passed as arguments must end with a trailing slash. Any content in these directories will be removed as well. SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Joey Hess <joeyh@debian.org> 11.1.6ubuntu2 2018-05-10 DH_CLEAN(1)
All times are GMT -4. The time now is 10:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy