Find folders that do NOT contain a certain file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Find folders that do NOT contain a certain file
# 1  
Old 04-05-2010
Find folders that do NOT contain a certain file

I'm no linux guru so any help would be greatly appreciated!

I need to output all folders that do not contain a file of a certain extension.

Currently I have the following

find / ! -name '*.txt' -printf %h\\n

This doesn't work because although it finds folders that do not contain *.txt, it outputs the folder for all other files that do not match *.txt

This is obviously not what I'm after.

Any help would be awesome!

Thanks,
# 2  
Old 04-05-2010
If I understand:
you want directories (not folders in unix) that do not contain files of the form [somename].txt

Do subdirectories count for this as well?
# 3  
Old 04-05-2010
Thanks for the reply Jim,

Correct.
The find command I listed was just an example.

I have a number of subdirectories within a folder called /vmfs/volumes/
There are an expected list of files within each of the subdirectories.

If one of these subdirectories is missing a file with the extension .vmx I will know it has either become corrupt or has not been deleted properly.

If I could output these subdirectories that no longer have a .vmx file I would be able track each down and deal with them.

Thanks again for the reply!

---------- Post updated at 03:33 PM ---------- Previous update was at 11:50 AM ----------

Managed to google my way to victory.

find /vmfs/volumes/v02tstn02a01/ -type d | while read dir; do if [ ! -f $dir/*.vmx ]; then echo $dir; fi; done;
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Find files in specific folders

Hi Team, I am new to the linux commands and I really need help . I would be really thankful if I can get some inputs. I have below folders in the path "/home/temp" 20170428 20170427 20170429 changes tempI need to get the files generated in the last 15 mins in all the above folders... (4 Replies)
Discussion started by: JackJinu
4 Replies

2. Shell Programming and Scripting

Find and Replace from specific folders

Hello Experts, Any help is appreciated. I would like to find and replace a string in a specific file ( e.g abc.xml) only for the directories starting with "AB 1.0 DIR". I've 50 sub directories starting with "AB 1.0 DIR". And I would like find the file abc.xml in those sub-directories and... (4 Replies)
Discussion started by: builderj
4 Replies

3. Shell Programming and Scripting

Bash to move specific files from folders in find file

I have a directory /home/cmccabe/nfs/exportedReports that contains multiple folders in it. The find writes the name of each folder to out.txt. A new directory is then created in a new location /home/cmccabe/Desktop/NGS/API, named with the date. What I am trying to do, unsuccessfully at the moment,... (7 Replies)
Discussion started by: cmccabe
7 Replies

4. SCO

Using FIND but ignoring selected folders

This may be ludicrously easy to most people, but I've been scratching my head today trying to do it. I'm archiving data on a OpenServer 5.0.6a box using a combination of FIND, CPIO and BZIP2. What I'd like to do is archive a range of folders, but ignore some. For instance, if I have 5... (1 Reply)
Discussion started by: mmcardle
1 Replies

5. Shell Programming and Scripting

Find empty folders

In current folder, there are many subfolders, subfolder's subfolders... under it. How can I find out the empty folders with no files in it. I only need the top folder list. For example, I have folders like below: a/b/c a/b/x/x.txt a/s a/s/y I need get the folder a/s, but not... (6 Replies)
Discussion started by: rdcwayx
6 Replies

6. UNIX for Dummies Questions & Answers

Removing empty folders using 'find'

Hey there! I try to use 'find' to remove empty directories like this: find . -depth -type d -empty -exec rm -rf {} ';' It works just fine, but there are some directories i want to exclude. So i tried to do sth like this: find . -depth -type d -empty -exec grep -v "not this one please" -exec... (5 Replies)
Discussion started by: deTTo
5 Replies

7. UNIX for Dummies Questions & Answers

Find and rename all folders with name X.

Is there a command I can use to rename all directories with a certain name to a new name. For instance from my root directory I want to change all folders named '123' to '321' that are in the root directory or any subdirectory. Thanks in advance! (6 Replies)
Discussion started by: mkingrey
6 Replies

8. UNIX for Advanced & Expert Users

find only folders

is there an option in find command to search only for folders (not subfolders). thx (1 Reply)
Discussion started by: melanie_pfefer
1 Replies

9. UNIX for Advanced & Expert Users

Script to Find Diff from two folders

Hi I would like to find the diff between two folders: Ex: Folder:1 html.java go.java ten.java Folder:2html.java go.java ten.java you.java Questions comes: Folder:1 contains a files with old version, know the files were modified and updated with the new version in Folder2. I... (2 Replies)
Discussion started by: gkrishnag
2 Replies

10. UNIX for Dummies Questions & Answers

Find file on server, searching thru many folders

Hi all, Is it possible to find a file on a server without knowing the file path? And when the file is found is it possible to find out the file path? I would like to find a file by typing: find server/ -name "filename" Instead of: find server/folder1/folder2/folder3/ -name "filename" Can... (5 Replies)
Discussion started by: Snakehead
5 Replies
Login or Register to Ask a Question