Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Restricting a Find search to the current directory only Post 302639069 by daveu7 on Friday 11th of May 2012 07:12:02 AM
Old 05-11-2012
Restricting a Find search to the current directory only

Hi All,

I am trying to delete file (with a mtime older than 2 days) from the current directory ONLY using:

Code:
find . -daystart -maxdepth 1 -mtime 2 -exec rm {} \;

but this doesn't seem to work it is still find files in subdirectories which I don't want to delete.

Please can anyone offer any advise about the use of the -maxdepth or do I need to use mindepth.

The man dialogue on the Find command states the following - what exactly does the phrase to the command line arguments mean ?

Man Find states:

Code:
 -maxdepth levels
              Descend at most levels (a non-negative integer) levels of directories below the command line arguments.  -maxdepth 0
               means only apply the tests and actions to the command line arguments.

       -mindepth levels
              Do not apply any tests or actions at levels less than levels (a non-negative integer).  -mindepth 1 means process all files  except  the
              command line arguments.

Many thanks for your help

Last edited by Scrutinizer; 05-11-2012 at 08:15 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

find directory not including current

Using Solaris 8, I've forgotten how to exclude the current directory in the find results. find . -type d ! -name "*.CAP" I want every directory that does not match the *.CAP pattern, except the current directory. (2 Replies)
Discussion started by: dangral
2 Replies

2. UNIX for Dummies Questions & Answers

Question about Restricting Search path of FIND to current directory

Hi, By default FIND command searches for matching files in all the subdirectories within the specified path. Is there a way to restrict FIND command's search path to only the specified directory and NOT TO scan its subdirectories. Any help would be more than appreciated. Thanks and Regards (2 Replies)
Discussion started by: super_duper_guy
2 Replies

3. UNIX for Dummies Questions & Answers

how to stop to current directory using find

Hello, I just want to ask the following use of find command: 1. how can I find files only to the current directory? 2. how can I find files to directories and all subdiretories (are this include soft links?) but will not go to other mountpoints that is under that mountpoint. Im combining... (1 Reply)
Discussion started by: james_falco
1 Replies

4. UNIX for Dummies Questions & Answers

Restrict my search to current directory.

Hi every1, There is a folder with .lst files which has email id's of our project group. I want to find files which has my email id starting with sachin but i dont want find command to search subdirectories. I have read about prune but i didnt understand that. I am pretty new in this field.... (7 Replies)
Discussion started by: sachin.gangadha
7 Replies

5. Shell Programming and Scripting

non recursive search in the current directory only

Hi, Am trying for a script which should delete more than 15 days older files in my current directory.Am using the below piece of code: "find /tmp -type f -name "pattern" -mtime +15 -exec /usr/bin/ls -altr {} \;" "find /tmp -type f -name "pattern" -mtime +15 -exec /usr/bin/rm -f {} \;" ... (9 Replies)
Discussion started by: puppala
9 Replies

6. Shell Programming and Scripting

Restricting zip to current directory only

I am using the following command in a C shell script: find . -name "*.*" -print | zip $ProjectZipFile -@ to zip files in a Unix (Sun and/or Linux) directory for archiving purposes. This command works fine, the only problem being that if sub-directories are present, they are included in... (5 Replies)
Discussion started by: phudgens
5 Replies

7. UNIX for Dummies Questions & Answers

find command to look for current directory only

i have this find command on my script as: for i in `find $vdir -name "$vfile" -mtime +$pday` the problem with this code is that the sub-directories are included on the search. how do i restrict the search to confine only on the current directory and ignore the sub-directories. please advise.... (7 Replies)
Discussion started by: wtolentino
7 Replies

8. Homework & Coursework Questions

C Program to search and read all named pipes in current directory

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: Write a C program to search the current directory for all pipes. 1. It will print the pipe... (2 Replies)
Discussion started by: natwickley
2 Replies

9. Shell Programming and Scripting

How to restrict Find only search the current directory?

hello, all I have googled internet, read the man page of Find, searched this forum, but still could not figure out how. My current directory is: little@wenwen:~$ pwd /home/little little@wenwen:~$ I want to use find command to list the files in my current directory, how should i write... (3 Replies)
Discussion started by: littlewenwen
3 Replies

10. Shell Programming and Scripting

Search: find current line, then search back

Hello. I want to find a line that has "new = 0" in it, then search back based on field $4 () in the current line, and find the first line that has field $4 and "last fetch" Grep or Awk preferred. Here is what the data looks like: 2013-12-12 12:10:30,117 TRACE last fetch: Thu Dec 12... (7 Replies)
Discussion started by: JimBurns
7 Replies
uuclean(1M)															       uuclean(1M)

NAME
uuclean - uucp spool directory clean-up SYNOPSIS
[options] DESCRIPTION
The commands, including are targeted for removal from HP-UX; see the below. scans the spool directories for files with the specified prefix and deletes all those that are older than the specified number of hours. Options recognizes the following options: Clean directory instead of the spool directory. If directory is not a valid spool directory, it cannot contain ``work files''; i.e., files whose names start with These files have special meaning to pertaining to job statistics. Scan for files with pre as the file prefix. Up to 10 arguments can be specified. A without any pre following will cause all files older than the specified time to be deleted. Files whose age is more than time hours are deleted if the prefix test is satisfied (default time is 72 hours). The default action for is to remove files that are older than a specified time (see option). The option is used to find files older than time hours; however, the files are not deleted. If the argument file is present the warning is placed in file; oth- erwise, the warnings go to the standard output. Only files destined for system sys are examined. Up to 10 arguments can be specified. The option sends mail to the owner of the file when it is deleted. If a file is specified, an entry is placed in file. This program is typically started by (see cron(1M)). WARNINGS
Use of commands, including is discouraged because they are targeted for removal from HP-UX. Use ftp(1) or rcp(1) instead. FILES
spool directory SEE ALSO
uucp(1), uux(1), cron(1M), uucleanup(1M). Tim O'Reilly and Grace Todino, O'Reilly & Associates, Inc. USA. Grace Todino and Dale Dougherty, O'Reilly & Associates, Inc. USA. TO BE OBSOLETED uuclean(1M)
All times are GMT -4. The time now is 09:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy