The UNIX find command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers The UNIX find command
# 1  
Old 07-09-2007
The UNIX find command

Hi All,

I trying to get my head around using the find command and i wanted to list a selection of files that are older than 30 days. i used 'find . -mtime +30' and it lists all the files including other files from the current location's sub directory. i then used the prune option but it seems it doesn't work 'find . -mtime +30 -prune'. The location i am trying to find files is in my local directory

/local/home/***/print/

the directory print has sub directory called 'backup'.

any help kindly appreciated.

Mani
# 2  
Old 07-09-2007
Add the "-level 0" option to the command
# 3  
Old 07-09-2007
Try:
find . -prune -mtime +30
# 4  
Old 07-10-2007
I may have read the posting incorrectly, but if you are attempting to exclude the the backup and/or print subdirectory and operate only on the the rest of the home, then:

find /local/home/username -name print -prune -o -mtime +30 -ls

mutliple prunes if you want (spaces important)

find /local/home/username \( -name print -o -name dir2 -o -name dir3 \) -prune -o -mtime +30 -print

-David
# 5  
Old 07-10-2007
hi, thanks for all your replies.

dmwaff, apologies for any misunderstanding, what i wanted was to find the contents 30+ days old only in the print directory and not its subdirectory "backup"

i tried :

find /local/home/*username*/print/ -name print -prune -o -mtime +30

and it returns everything 30+ days old in 'print' and in the sub directory 'backup'.

i tried:

find . -prune -mtime +30

and it doesn't return anything even with a -ls option at the end.


i went back one directory into my username directory and tried the following commands

find . -name 'print' -mtime +30
find ./ -name print -mtime +30

but nothing, no display or error message of incorrect usage even with an -ls or -prune option. I did a check on the contents of the directory and there are files dating back from 2006, from May and June 2007, which it should pick up and display Smilie Smilie
# 6  
Old 07-10-2007
To find files (not directories) in the current directory old than 30 days without descending into subdirectories, use:
find . ! -name . -prune -type f -mtime +30

If you want to find old directories too without descending into them:
find . ! -name . -prune -mtime +30
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Unix find and head command help

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I've been stuck on this problem for 2 days now What command would you enter to list the first lines of all text... (11 Replies)
Discussion started by: partieboi37
11 Replies

2. UNIX for Dummies Questions & Answers

unix find command

This command is intended to compare two drives to see if all files are identical, can some one please decode what it is doing. find / -path /proc -prune -o -path /new-disk -prune -o -xtype f -exec cmp {} /new-disk{} \; (2 Replies)
Discussion started by: Tirmazi
2 Replies

3. Shell Programming and Scripting

What is find and replace command in unix?

hello forum memvers, 1:I have to write a script for find a string and replace with another string. 2:In shell script how to replace one string with another string.:b: (4 Replies)
Discussion started by: rajkumar_g
4 Replies

4. Shell Programming and Scripting

unix find command

I need help with tweaking the unix find command. currently the find command searches all the directories under $div/users modified in the last 1 day. find $div/users -type d -mtime +1 I need this changed to find only subdirectories and sub-subdirectories modified in the last 1 day under... (3 Replies)
Discussion started by: mnnarendra
3 Replies

5. UNIX for Dummies Questions & Answers

unix find command

I need help with tweaking the unix find command. currently the find command searches all the directories under $div/users modified in the last 1 day. find $div/users -type d -mtime +1 I need this changed to find only subdirectories and sub-subdirectories modified in the last 1 day under... (1 Reply)
Discussion started by: mnnarendra
1 Replies

6. Shell Programming and Scripting

Little bit weired : Find files in UNIX w/o using find or where command

Yes , I have to find a file in unix without using any find or where commands.Any pointers for the same would be very helpful as i am beginner in shell scritping and need a solution for the same. Thanks in advance. Regards Jatin Jain (10 Replies)
Discussion started by: jatin.jain
10 Replies

7. Shell Programming and Scripting

how to find a file in UNIX without find command?

given a start directory,a filename,how to find it? (3 Replies)
Discussion started by: bluo
3 Replies

8. UNIX for Dummies Questions & Answers

how to find a command in Unix?

How can I know that my FreeBSD OS has commands mkdir or mkfile? Can I do like this: find / -name mkdir find / -name mkfile But I do not see them??? Thanks. (1 Reply)
Discussion started by: lacasa
1 Replies
Login or Register to Ask a Question