Searching for files over 30 days old in current directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Searching for files over 30 days old in current directory
# 8  
Old 10-31-2003
You almost had it right, oombera...

find . \( ! -name . -prune \) -mtime +30
# 9  
Old 10-31-2003
Its great. Perderabo's solution works. But can somebody explain how the order of options is changing the output here ??
# 10  
Old 10-31-2003
i didnt know about the prune option.

it seems to be an order of presidence useing Perderabo version.

find the files. then only select the ones that are 30days old.

vs. find anything that is 30 days old then (this part is negated?) find files in the current directory.
# 11  
Old 10-31-2003
find does stuff in order.

With
find . -mtime +30 \( ! -name . -prune \)
a candidate entry in . must first pass the "-mtime +30" test. Only then do we see if we want to prune it or not.
# 12  
Old 03-29-2006
hi for this command
find $PWD -type f -mtime +30 -print|grep -Ev "$PWD/.*/"

can i know the usage for E in grep -Ev
this produce error when i use it.
grep: illegal option -- E
Usage: grep -hblcnsviw pattern file . . .
# 13  
Old 03-29-2006
You must have a very old grep. -E is required by posix. It allows extended regular expressions. You might have an egrep program that can do extended regular expressions.
# 14  
Old 05-29-2006
find -maxdepth 1

Maybe I'm misunderstanding, but seems to me if all you want to do is prevent recursing into subdirectories you could also do this with

find -maxdepth 1
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Searching for a files based on current date directory

Hi All, I've been trying to do some recursive searching but not been very successful. Can someone please help. Scenario: I have directory structure /dir1/dir2/dir3/ 2019/ 11/ 17 18 19 20 so what I want to do is run a script and as its 2019/11/18/ today it would go and only search... (3 Replies)
Discussion started by: israr75
3 Replies

2. UNIX for Advanced & Expert Users

Find all files in the current directory excluding hidden files and directories

Find all files in the current directory only excluding hidden directories and files. For the below command, though it's not deleting hidden files.. it is traversing through the hidden directories and listing normal which should be avoided. `find . \( ! -name ".*" -prune \) -mtime +${n_days}... (7 Replies)
Discussion started by: ksailesh1
7 Replies

3. Shell Programming and Scripting

How to clean 3 days before files, from a directory?

I have a Solaris System. I am using bash shell. I want to prepare a script which can do the below. There are few directories i need to clean. In those directories, I need to delete files which are older than 3 days. 3 days before files need to be deleted. The directories are as follows.... (7 Replies)
Discussion started by: Saidul
7 Replies

4. UNIX for Dummies Questions & Answers

Need Help in reading N days files from a Directory & combining the files

Hi All, Request your expertise in tackling one requirement in my project,(i dont have much expertise in Shell Scripting). The requirement is as below, 1) We store the last run date of a process in a file. When the batch run the next time, it should read this file, get the last run date from... (1 Reply)
Discussion started by: dsfreddie
1 Replies

5. Shell Programming and Scripting

How to strip ^M at end of each files for all files found in current directory

I am trying to use a loop to strip of the funny character ^M at the end of all lines in each file found in current directory and I have used the following in a script: find . -type f -name '*.txt' | while read file do echo "stripping ^M from ..." ex - "$file" > $tempfile %s/^M//g wq! # mv... (4 Replies)
Discussion started by: bisip99
4 Replies

6. Shell Programming and Scripting

mget * (obtein files from current directory but not the files form sub-directories)

Hello, Using the instruction mget (within ftp) and with "Interactive mode off", I want to get all files from directory (DirAA), but not the files in sub-directories. The files names don't follow any defined rule, so they can be just letters without (.) period Directory structure example: ... (0 Replies)
Discussion started by: Peter321
0 Replies

7. Shell Programming and Scripting

Finding files in current directory when 100,000's files in current directory

Hi All I was wondering what is the most efficient way to find files in the current directory(that may contain 100,000's files), that meets a certain specified file type and of a certain age. I have experimented with the find command in unix but it also searches all sub directories. I have... (2 Replies)
Discussion started by: kewong007
2 Replies

8. Shell Programming and Scripting

searching content of files in the current and sub directories

Hi I was wondering why command 2 doesn't work like command 1 below. 1. find . -exec grep "test" '{}' \; -print 2. ls -R | grep "test" I am trying to search "test" from all the files in the current and sub directories. What's wrong with my command 2? Thanks in advance for your help (4 Replies)
Discussion started by: tiger99
4 Replies

9. Shell Programming and Scripting

searching files through all subdirectories beneath the current directory

i want to make a bash script that searches a specific pattern in files through all subdirectories beneath the current directory..without using the command grep-R but only the command grep.. e.g for i in * do grep "pattern" $i ..... ... done using the character (*) the script... (5 Replies)
Discussion started by: milagros
5 Replies

10. Shell Programming and Scripting

ls latest 4 days or specify days of files in the directory

Hi, I would like to list latest 2 days, 3 days or 4 days,etc of files in the directory... how? is it using ls? (3 Replies)
Discussion started by: happyv
3 Replies
Login or Register to Ask a Question