Sponsored Content
Top Forums Shell Programming and Scripting How to delete subdirectories that are more than 1 day old AND have NO files on them Post 302541834 by ajaypatil_am on Tuesday 26th of July 2011 01:11:19 AM
Old 07-26-2011
thanks it worked ...2 more questions ....
1) now i want to delete ALL the dirs , suddirs in a particular dir ....i am using rm -rf dirname but it is taking very long time ...is there any faster way ? will following script faster ?

find . -type d | while read d; do

rm -rf "$d"
done

2) why rmdir -rf is not working for me ?.see below

> rmdir -rf DSF_DECOM
rmdir: illegal option -- r
rmdir: illegal option -- f
Usage: rmdir [-ps] dirname ...
> rmdir -r DSF_DECOM
rmdir: illegal option -- r
Usage: rmdir [-ps] dirname ...
> rmdir DSF_DECOM
rmdir: directory "DSF_DECOM": Directory not empty



Thanks,
A

Quote:
Originally Posted by yazu
Yes.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

delete files one day old in current month only

i want to delete files that are one day old condition is files should be of current month only ie if iam running script on 1 march it should not delete files of 28 feb(29 if leap year :-)} any modifications to find $DIR -type f -atime +1 -exec rm -f{}\; (4 Replies)
Discussion started by: maverick
4 Replies

2. Shell Programming and Scripting

Not able to delete the files in day wise...

Dear All, I am not able to remove the files in my AIX 5.3 server. My files List /iims-home/data/uat1/batch/staging -rw-r--r-- 1 iims iims 5743 Jun 12 09:04 ErrorReport2008-05-20 09-04-18.doc -rw-r--r-- 1 iims iims 191213683 Jun 12 09:05... (1 Reply)
Discussion started by: bvijaycom
1 Replies

3. Shell Programming and Scripting

How to delete files which more than one Day old?

I have a directory /opt/targets which generates more than 1000 files per day and I want to delete all the files which are more than 1 day old...ie 24hrs+ Please help.. (3 Replies)
Discussion started by: sunilrk07
3 Replies

4. Shell Programming and Scripting

Delete all the files and subdirectories for the year 2006

Hi I have lot of files and subdirectories inside a directory which are created in the years 2006, 2007, 2008, 2009 and 2010. I want to delete all the files and subdirectories belonging to the year 2006 alone. How can I do that ? (5 Replies)
Discussion started by: samsungsamsung
5 Replies

5. UNIX for Dummies Questions & Answers

Move the files between Current day & a previous day

Hi All, I have a requirement where I need to first capture the current day & move all the files from a particular directory based on a previous day. i.e move all the files from one directory to another based on current day & a previous day. Here is what I am trying, but it gives me errors.... (2 Replies)
Discussion started by: dsfreddie
2 Replies

6. AIX

Want to delete directory, subdirectories and all files which are older than 7 days

how do i remove sub directories of a directory and all files which are older than 7 days by a single command in AIX. pls help me. I am using command as #find /gpfs1/home/vinod/hpc/ -depth -type d -mtime +7 -exec rm -rf {} \; so i want to delete all sub directories and all files from the... (1 Reply)
Discussion started by: vinodkmpal
1 Replies

7. Shell Programming and Scripting

Append string to all the files inside a directory excluding subdirectories and .zip files

Hii, Could someone help me to append string to the starting of all the filenames inside a directory but it should exclude .zip files and subdirectories. Eg. file1: test1.log file2: test2.log file3 test.zip After running the script file1: string_test1.log file2: string_test2.log file3:... (4 Replies)
Discussion started by: Ravi Kishore
4 Replies

8. Shell Programming and Scripting

Delete file to day

friends how I can delete files from a directory for the current date? (2 Replies)
Discussion started by: tricampeon81
2 Replies

9. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies

10. UNIX for Beginners Questions & Answers

Delete records that do not belong to that day

i have a requirement to delete records that do not belong to that day. For example in a file that came on July 31st ,2018 there are records that belong to Aug 1st,2018 as well and I want to find and delete those records. I want to delete anything with 01-Aug-2018. I have several files like that. I... (6 Replies)
Discussion started by: Priya
6 Replies
explain_rmdir_or_die(3) 				     Library Functions Manual					   explain_rmdir_or_die(3)

NAME
explain_rmdir_or_die - delete a directory and report errors SYNOPSIS
#include <libexplain/rmdir.h> void explain_rmdir_or_die(const char *pathname); DESCRIPTION
The explain_rmdir_or_die function is used to call the rmdir(2) system call. On failure an explanation will be printed to stderr, obtained from explain_rmdir(3), and then the process terminates by calling exit(EXIT_FAILURE). This function is intended to be used in a fashion similar to the following example: explain_rmdir_or_die(pathname); pathname The pathname, exactly as to be passed to the rmdir(2) system call. Returns: This function only returns on success. On failure, prints an explanation and exits. SEE ALSO
rmdir(2) delete a directory explain_rmdir(3) explain rmdir(2) errors exit(2) terminate the calling process COPYRIGHT
libexplain version 0.52 Copyright (C) 2008 Peter Miller explain_rmdir_or_die(3)
All times are GMT -4. The time now is 01:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy