Using FIND but ignoring selected folders


 
Thread Tools Search this Thread
Operating Systems SCO Using FIND but ignoring selected folders
# 1  
Old 03-03-2013
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 folders:

/test1
/test2
/test3
/test4
/test5

how do I cpio test1 to test4, but ignore test5?

I've been trying to use find . ! - name test5

But it just ignores the folder, not the files in the folder.

Hope I've explained that sufficiently.

Many thanks for any advice.

---------- Post updated 04-03-13 at 12:00 AM ---------- Previous update was 03-03-13 at 11:42 PM ----------

I think I've figured this out:

find . | grep -v test5/
# 2  
Old 03-03-2013
You could also try:
Code:
find . \( -name test5 -prune \) -o -print

or if you only want files rooted in test1, test2, test3, and test4 (and not other files in the current directory):
Code:
find test[1-4]

This User Gave Thanks to Don Cragun For This Post:
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

Find key pattern and print selected lines for each record

Hi, I need help on a complicated file that I am working on. I wanted to extract important info from a very huge file. It is space delimited file. I have hundred thousands of records in this file. An example content of the inputfile as below:- ## ID Ser402 Old; 23... (2 Replies)
Discussion started by: redse171
2 Replies

3. Shell Programming and Scripting

Script to find and email selected files

I am trying to come up with a script that will search for selected files and then email them to me. For example, say I have a directory that has the following files: AA_doug.txt AA_andy.txt BB_john.txt APPLE_mike.txt GLOBE_ed.txt GLOBE_tony.txt TOTAL_carl.txt what is the best way to... (2 Replies)
Discussion started by: coach5779
2 Replies

4. Shell Programming and Scripting

trying to print selected fields of selected lines by AWK

I am trying to print 1st, 2nd, 13th and 14th fields of a file of line numbers from 29 to 10029. I dont know how to put this in one code. Currently I am removing the selected lines by awk 'NR==29,NR==10029' File1 > File2 and then doing awk '{print $1, $2, $13, $14}' File2 > File3 Can... (3 Replies)
Discussion started by: ananyob
3 Replies

5. UNIX for Dummies Questions & Answers

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,... (2 Replies)
Discussion started by: hodnov
2 Replies

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

7. Shell Programming and Scripting

Ignoring package contents with find

Hi everyone, I use the command find to get all folder contents of a folder. The problem is, it also gives files from within other files with package contents. (.app, .rtfd, ...). Is there anyway to not do that ? find /path/to/my/folder/ ! -name '.*'" (I'm using OS X, I don't know if other... (0 Replies)
Discussion started by: JamesGreen
0 Replies

8. UNIX for Dummies Questions & Answers

Find & Copy Selected files to another Directory

I am wanting to find files within a directory that are over a certain number of days old and copy them to another directory. And unfortunately not having much luck.......is someone able to help. Would also like to add that there are literally thousands of files that I am wanting to copy in one... (3 Replies)
Discussion started by: hellfyre
3 Replies

9. Shell Programming and Scripting

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... (4 Replies)
Discussion started by: osramos
4 Replies

10. 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
Login or Register to Ask a Question