Find files ignoring subdirectories


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find files ignoring subdirectories
# 1  
Old 12-02-2008
Find files ignoring subdirectories

Hi guys,

I am searching some files not equal to the pattern with this command

find ! -name "PATTERN" -type f

but my problem is the find command because he also search inside subdirectories and that's the thing i don't want that.

Is there any comand to ignore the directories or subdirectories?

Regards,

osramos
# 2  
Old 12-02-2008
Code:
ls -l | grep -v ^d | grep -v "what you dont want"

Code:
Only Flat Files:
ls -1Ap | grep -v /\$

Only Directories:
ls -1Ap | grep /\$ | sed -e"s/[/]//g"
ls -1Ap | grep /\$ | cut -d/ -f1


Last edited by Ikon; 12-02-2008 at 06:46 PM..
# 3  
Old 12-02-2008
Ok, thanks a lot.

That means the find command doesn't hane no tricky stuff to ignore sub-directories?

Regards

osramos
Quote:
Originally Posted by Ikon
Code:
ls -l | grep -v ^d | grep -v "what you dont want"

Code:
Only Flat Files:
ls -1Ap | grep -v /\$

Only Directories:
ls -1Ap | grep /\$ | sed -e"s/[/]//g"
ls -1Ap | grep /\$ | cut -d/ -f1

# 4  
Old 12-02-2008
Yes, there is. Including the option -not -name will make find exclude matching dir or files. Tested on FreeBSD:

Code:
find dir -not -name "bin"

will exclude dir or file named bin
# 5  
Old 12-02-2008
depending on the version of find this might work

Code:
find . -maxdepth 1 -type f

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

AIX : Find files ignoring certain file extensions

Hi All, I am scripting a program to find and archive files. There are certain file types that I do not want to archive. Below is the scenario. I have created a lookup file which has details on folders days and file extensions that needs to be ignored I have separated the individual into... (4 Replies)
Discussion started by: kavinmjr
4 Replies

2. Shell Programming and Scripting

Search subdirectories and find and print total files

Hi All, I have a folder name lets say path/to/folder/CUSTOMER and under this i have several folders and each of these subfolder have serveral subfolders and so on and at some point i will have a folder name called "FTP_FILES" . I need to search for these folders named "FTP_FILES and then... (10 Replies)
Discussion started by: Kevin Tivoli
10 Replies

3. Shell Programming and Scripting

Find files only in current directory...not subdirectories

Hi, I have to find 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 tried to use maxdepth..but it is not working in AIX. (2 Replies)
Discussion started by: vsachan
2 Replies

4. Shell Programming and Scripting

Find *.tar files under all subdirectories

Hi there, I'm new to shell scripting... I've a situation like to find *.tar files under all subdirectories in "/home/abcd" and i used the below, find /opt/lhapp ! -name "temp" | more the above works fine.. Now don't need search few direcotries like "/home/abcd/aaaa",... (15 Replies)
Discussion started by: skcvasanth
15 Replies

5. Shell Programming and Scripting

how can i find number of lines in files & subdirectories

how can i find number of lines in files & subdirectories ? (3 Replies)
Discussion started by: pcbuilder
3 Replies

6. Shell Programming and Scripting

How to find files only inside the subdirectories only?

Hi I have a directory with two subdirectories and also have a code like below to search files modified in last 2 minutes. # ls hello080909.txt inbox outbox # find . -type f -mmin +2 ./inbox/hello2080909.txt ./outbox/hi0080909.txt ./hello080909.txt The above code just searches and... (3 Replies)
Discussion started by: Tuxidow
3 Replies

7. Shell Programming and Scripting

to parse a directory and its subdirectories and find owner name of files

hi all, i need to capture all the files in a directory and its subdirectories that have owner name different than the root owner. for one file it is " stat -c %U filename " but i need to search for each and every file and record it. thanks in advance (14 Replies)
Discussion started by: vyasa
14 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

Shell:Find a word in files in a directory and subdirectories

I'm looking to write a ksh code with will be alble to find a word like 'toto' in all files going from my current directory. eg. /doc ----------->have: text.c which "toto" /doc/usr-------->have: build.pc, help.java which "toto" /doc/usr/cach -->have: test.sh which "toto" /doc/build... (4 Replies)
Discussion started by: yeclota
4 Replies

10. UNIX for Dummies Questions & Answers

Find all files created by a specified user in a directory and its subdirectories

Is there a command or shell script which can be used for Finding all files created by a specified userid in a directory and its subdirectories. Say, I want to find all such files in directory /abc as well as in all the subdirectories such as /abc/xyz or /abc/xyz/pqr aqnd so on which was created... (5 Replies)
Discussion started by: abhilashnair
5 Replies
Login or Register to Ask a Question