Sponsored Content
Top Forums Shell Programming and Scripting How to delete files in UNIX using shell script Post 97908 by hegemaro on Friday 3rd of February 2006 08:18:36 AM
Old 02-03-2006
Piping the previous command into wc

find /path/to/directory -mtime +5 -ok rm -f {} \; | wc -l

will give you a line count.

If you're confident in what you're deleting, and you VERIFY that the directory provided isn't a system directory, you can streamline the command without a prompt. Also, add one more exprssion to make certain you're deleting only FILES:

find /path/to/directory -mtime +5 -type f -print -exec rm -f {} \; 1>/tmp/out
wc -l /tmp/out

The print command displays the file being deleted. I'd recommend saving the output for review. You can then do a line count on the output file.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

how to delete empty files in a shell script

I'm trying to figure out a way to delete empty files in a directory. I have a cron that runs and creates a flat file every 15 mins. However, most times at night the flat file will be empty. I'd like to run a script to delete empty files that end with *.dat Any suggestions? Rich (1 Reply)
Discussion started by: rpnuge
1 Replies

2. Shell Programming and Scripting

shell script for delete old files

i want to delete all the files in my directory except the latest one. i need to do this from shell script. say i have a.txt - latest file b.txt, c.txt.. it should delete all the files except a.txt? (4 Replies)
Discussion started by: krishnarao
4 Replies

3. Shell Programming and Scripting

Delete files older than 2 days using shell script in Unix

I'm new to shell script.... can any one help... What is the shell script to delete the files older than 2 days ? (3 Replies)
Discussion started by: satishpabba
3 Replies

4. Shell Programming and Scripting

delete old files thru unix script

I have to delete files older than 60 days from a windows directory. So I tried to include this script FTP_LOG=${DATA_TOP}/data_tmp/logfile FTP_CMDS=${DATA_TOP}/data_tmp/cmdfile echo "open ftp1" > ${FTP_CMDS} echo "user anonymous local" >> ${FTP_CMDS} echo "cd ${SRC_DIR}" >> ${FTP_CMDS} echo... (3 Replies)
Discussion started by: snair001
3 Replies

5. Shell Programming and Scripting

perl script to check if empty files are created and delete them and run a shell script

I have a local linux machine in which the files are dumped by a remote ubuntu server. If the process in remote server has any problem then empty files are created in local machine. Is there any way using perl script to check if the empty files are being created and delete them and then run a shell... (2 Replies)
Discussion started by: hussa1n
2 Replies

6. Shell Programming and Scripting

Unix shell script to delete files on windows server

Hi experts, can anyone suggest me on the below: how to write a shell script to search and delete files on windows server. -script runs on unix box -it should search for specific files on windows server and delete them periodically. (2 Replies)
Discussion started by: chpradeepch
2 Replies

7. Shell Programming and Scripting

Shell Script to delete the protected files.

Hello, we have more than 100000 files in a directory which are write-protected regular file, these files are quite old and would like to delete them completely, Kindly let me know the command or peice of code to automate the process. The filenames are like below MPNT_... (6 Replies)
Discussion started by: Hadoop_Master
6 Replies

8. Shell Programming and Scripting

Shell script to check a file and delete old files

Hello, I needed help with a shell script where in it checks if a file exists under a directory and also checks the age of the file and delete it if it is older than 3 weeks. thanks (10 Replies)
Discussion started by: hasn318
10 Replies

9. Shell Programming and Scripting

Shell Script to delete files from 5 different servers

Hello, I'm new to shell scripting and need a quick note on how to write a shell script to perform deletion of files from 5 different hostnames in various locations. Found out to delete files from one path by using below command and made it to work on cron job but need to do it in a shell... (2 Replies)
Discussion started by: Teja G
2 Replies

10. Shell Programming and Scripting

Shell script to delete the ip address from files

Hello, I am new to shell scripting, need help, my requirement is to delete the ip address from serveral files, please suggest (2 Replies)
Discussion started by: manoj.solaris
2 Replies
DH_INSTALLDEB(1)						     Debhelper							  DH_INSTALLDEB(1)

NAME
dh_installdeb - install files into the DEBIAN directory SYNOPSIS
dh_installdeb [debhelperoptions] DESCRIPTION
dh_installdeb is a debhelper program that is responsible for installing files into the DEBIAN directories in package build directories with the correct permissions. FILES
package.postinst package.preinst package.postrm package.prerm These maintainer scripts are installed into the DEBIAN directory. Inside the scripts, the token #DEBHELPER# is replaced with shell script snippets generated by other debhelper commands. package.triggers package.shlibs These control files are installed into the DEBIAN directory. Note that package.shlibs is only installed in compat level 9 and earlier. In compat 10, please use dh_makeshlibs(1). package.conffiles This control file will be installed into the DEBIAN directory. In v3 compatibility mode and higher, all files in the etc/ directory in a package will automatically be flagged as conffiles by this program, so there is no need to list them manually here. package.maintscript Lines in this file correspond to dpkg-maintscript-helper(1) commands and parameters. However, the "maint-script-parameters" should not be included as debhelper will add those automatically. Example: # Correct rm_conffile /etc/obsolete.conf 0.2~ foo # INCORRECT rm_conffile /etc/obsolete.conf 0.2~ foo -- "$@" In compat 10 or later, any shell metacharacters will be escaped, so arbitrary shell code cannot be inserted here. For example, a line such as "mv_conffile /etc/oldconffile /etc/newconffile" will insert maintainer script snippets into all maintainer scripts sufficient to move that conffile. It was also the intention to escape shell metacharacters in previous compat levels. However, it did not work properly and as such it was possible to embed arbitrary shell code in earlier compat levels. The dh_installdeb tool will do some basic validation of some of the commands listed in this file to catch common mistakes. The validation is enabled as a warning since compat 10 and as a hard error in compat 12. SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Joey Hess <joeyh@debian.org> 11.1.6ubuntu2 2018-05-10 DH_INSTALLDEB(1)
All times are GMT -4. The time now is 08:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy