Sponsored Content
Top Forums UNIX for Advanced & Expert Users Find all files in the current directory excluding hidden files and directories Post 302886637 by Don Cragun on Monday 3rd of February 2014 02:53:23 AM
Old 02-03-2014
The -prune primary in find ignores everything except directories, but the combination! -name ".*" -prune does not prune directories with names starting with a period. A rough equivalent of -maxdepth 1 for use in versions of find that don't have the -maxdepth primary is \( ! -name . -prune \).

If there is no -exec primary, no -ok primary, and no -print primary in the expression given to find, the -print primary is supplied by default.

The following is a slightly simpler command than MadeInGermany's suggestion and should produce the same results:
Code:
find . \(  ! -name . -prune \) ! -name ".*" -type f -mtime +${n_days}

This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

find excluding the hidden files

Hi , I am trying to use the find command with delete in a directory . Even though i use a wil character search the find command is checking the hidden files which inturn results in error . Can i avoid look that into the hidden files ?? I am using HP unix . find /cv1/ -name "ite*"... (3 Replies)
Discussion started by: arunkumar_mca
3 Replies

2. UNIX for Dummies Questions & Answers

Find Files in a Directory Excluding Subdirectories

Hi, I have a filename Location.txt in a directory /abc. Similar name file is present in its subdirectory /abc/xyz. I want to find the file which is present only in /abc and not in /abc/xyz. Please any1 of u can provide a quick suggestion. Its very urgent. Thanks, Amol (2 Replies)
Discussion started by: Amol_Dicholkar
2 Replies

3. UNIX for Dummies Questions & Answers

List files that are not directories from current directory

I can't manage to list all files that are not directories from current directory. (2 Replies)
Discussion started by: beni22sof
2 Replies

4. 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

5. Shell Programming and Scripting

Find all files for a user, excluding a directory

I have been searching, and cannot find an answer for this. I am trying to find all files for a user, lets call him (test001), and I want to exclude a specific directory. Here is the command I run, it finds all files: find / -user test001 I get this result: > find / -user test001 ... (4 Replies)
Discussion started by: steve2x4
4 Replies

6. Shell Programming and Scripting

How to list all the files, directories and sub-directories in the current path except one directory?

Can anyone come up with a unix command that lists all the files, directories and sub-directories in the current directory except a folder called log.? Thank you in advance. (7 Replies)
Discussion started by: Manjunath B
7 Replies

7. Shell Programming and Scripting

Find specific files only in current directory...not sub directories AIX

Hi, I have to find specific files only in the current directory...not in the sub directories. But when I use Find command ... it searches all the files in the current directory as well as in the subdirectories. I am using AIX-UNIX machine.Please help.. I am using the below command. And i am... (2 Replies)
Discussion started by: aakishore
2 Replies

8. Shell Programming and Scripting

Find command to search files in a directory excluding subdirectories

Hi Forum, I am using the below command to find files older than x days in a directory excluding subdirectories. From the previous forums I got to know that prune command helps us not to descend in subdirectories. Though I am using it here, not getting the desired result. cd $dir... (8 Replies)
Discussion started by: jhilmil
8 Replies

9. Shell Programming and Scripting

Find/searching files in subdirectories excluding the fiels in Parent Directory

Hi All, requirement is to find and remove the files from sub directories but it should exclude the files from parent directory. At present i am using the below one but it finds and remove files from both parent and sub directories. find ${PATH} -type f \( -name securitas\* -o -name \*gz... (1 Reply)
Discussion started by: Naveenkk
1 Replies

10. Shell Programming and Scripting

Find command excluding directories and some files

hello. I try to print a list of files but excluding some directories and some files. I would like to write a command for : find "from_dir" "ignore dir1, dir2, ..." "ignore file1, file2,...." "where file are older than 2017-02-03T06:00:00" Note that "DO_IT" is a local function in the script... (5 Replies)
Discussion started by: jcdole
5 Replies
File::Find::Rule::VCS(3pm)				User Contributed Perl Documentation				File::Find::Rule::VCS(3pm)

NAME
File::Find::Rule::VCS - Exclude files/directories for Version Control Systems SYNOPSIS
use File::Find::Rule (); use File::Find::Rule::VCS (); # Find all files smaller than 10k, ignoring version control files my @files = File::Find::Rule->ignore_vcs ->file ->size('<10Ki') ->in( $dir ); DESCRIPTION
Many tools need to be equally useful both on ordinary files, and on code that has been checked out from revision control systems. File::Find::Rule::VCS provides quick and convenient methods to exclude the version control directories of several major Version Control Systems (currently CVS, subversion, and Bazaar). File::Find::Rule::VCS implements methods to ignore the following: CVS Subversion Bazaar In addition, the following version control systems do not create directories in the checkout and do not require the use of any ignore methods SVK Git METHODS
ignore_vcs # Ignore all common version control systems $find->ignore_vcs; # Ignore a specific named version control systems $find->ignore_vcs($name); # Ignore nothing (silent pass-through) $find->ignore_vcs(''); The "ignore_vcs" method excludes the files for a named Version Control System from your File::Find::Rule search. If passed, the name of the version control system is case in-sensitive. Names currently supported are 'cvs', 'svn', 'subversion', 'bzr', and 'bazaar'. As a convenience for high-level APIs, if the VCS name is the defined null string '' then the call will be treated as a nullop. If no params at all are passed, this method will ignore all supported version control systems. If ignoring every version control system, please note that any legitimate directories called "CVS" or files starting with .# will be ignored, which is not always desirable. In widely-distributed code, you instead should try to detect the specific version control system used and call ignore_vcs with the specific name. Passing "undef", or an unsupported name, will throw an exception. ignore_cvs The "ignore_cvs" method excluding all CVS directories from your File::Find::Rule search. It will also exclude all the files left around by CVS after an automated merge that start with '.#' (dot-hash). ignore_rcs The "ignore_rcs" method excluding all RCS directories from your File::Find::Rule search. It will also exclude all the files used by RCS to store the revisions (end with ',v'). ignore_svn The "ignore_svn" method excluding all Subversion (".svn") directories from your File::Find::Rule search. ignore_bzr The "ignore_bzr" method excluding all Bazaar (".bzr") directories from your File::Find::Rule search. ignore_git The "ignore_git" method excluding all Git (".git") directories from your File::Find::Rule search. ignore_hg The "ignore_hg" method excluding all Mercurial/Hg (".hg") directories from your File::Find::Rule search. TO DO
- Add support for other version control systems. - Add other useful VCS-related methods SUPPORT
Bugs should always be submitted via the CPAN bug tracker <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Find-Rule-VCS> For other issues, contact the maintainer AUTHOR
Adam Kennedy <adamk@cpan.org> SEE ALSO
<http://ali.as/>, File::Find::Rule COPYRIGHT
Copyright 2005 - 2010 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.10.1 2010-10-06 File::Find::Rule::VCS(3pm)
All times are GMT -4. The time now is 05:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy