find excluding the hidden files


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users find excluding the hidden files
# 1  
Old 01-25-2008
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*" -mtime +14 -exec rm -f -r

HIw can modify the above command so that i exclude the hedden files or directory when searching ..

PLease let me know if is urgent

Thanks,
Arun
# 2  
Old 01-26-2008
Question

Quote:
Originally Posted by arunkumar_mca
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*" -mtime +14 -exec rm -f -r

HIw can modify the above command so that i exclude the hedden files or directory when searching ..

PLease let me know if is urgent

Thanks,
Arun
Check the syntax of the find command. It is missing the curly braces {} that represent the files returned by find and it should be terminated by an escaped semi-colon \;

Code:
find /cv1/ -name "ite*" -mtime +14 -exec rm -fr {} \;

I am not sure what you mean by hidden files or directories?
# 3  
Old 01-26-2008
He means files prepended with a period, .hidden for example.

You can use a regex to exclude these files and directories:

find . \( ! -regex '.*/\..*' \)
# 4  
Old 01-27-2008
Hi

find /wsfer/cre/ -name "mod*" -mtime +14 -exec rm -f -r 2> /dev/null "{}" ";"

This was the command i used the syntax was right ..
I even though tried the regex you suggested it was not working . I am using HP UNIX.

Even though i used /dev/null after this command when i tried $? the status i am geeting is 1 if the permision denied . Why it is happening .
And how to exclude the hidden files and directory in the above command . Please help.

Thanks
Arun.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Rsync - how to copy hidden folder or hidden files when using full path

Hello. I use this command : rsync -av --include=".*" --dry-run "$A_FULL_PATH_S" "$A_FULL_PATH_D"The data comes from the output of a find command. And no full source directories are in use, only some files. Source example... (2 Replies)
Discussion started by: jcdole
2 Replies

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

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

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

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

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

7. Shell Programming and Scripting

Find files of specific size excluding search in a subdirectory

Hi All, I was exploring find command and came across -prune option which would exclude search in a mention subdirectory. My quesry is to search all files more that 100 MB size but exclude search in a subdirectory. I am using below command,but somehow it is not working. Can anybody help me... (6 Replies)
Discussion started by: usha rao
6 Replies

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

9. Shell Programming and Scripting

Finding Hidden files and protecting the folder containing hidden files from deletion

Hi. I have a script which is deleting files with a particular extension and older than 45 days.The code is: find <path> -name "<filename_pattern>" -mtime +45 -exec rm {} \; But the problem is that some important files are also getting deleted.To prevent this I have decide to make a dummy... (4 Replies)
Discussion started by: pochaw
4 Replies
Login or Register to Ask a Question