Excluding directories from a find


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Excluding directories from a find
# 8  
Old 08-12-2012
Quote:
1)What does the + sign do?
See man find for your system (whatever that is?). If it is not there, just use \; as usual. The + can be faster on certain Operating System (e.g. modern Solaris).

Quote:
2) Thanks for the comment about the whitespace-I hadn't thought about that. (I don't believe that whitespace is legal on an apache server, but the MD5 does work on files in the tree that contain white space (I tested it)). If I did need to use a directory that incudes whitespace, could I just include escape sequences in the exclude variables?
Apache is a package which you can install on unix of Linux. Whether it be unix of Linux, the Operating System will support space characters in filenames.

The sentence supplement containing "MD5" makes no sense whatsoever to me.

"Escape Sequences" are usually associated with driving special effects on Printers and VDUs. What do you mean?

Please provide examples of awkward directory names which you wish to exclude (blotting anything confidential with X's).
When the list gets awkward the best approach is to use sed with a sedfile to eliminate unwanted file or directory names. Using a sedfile means that the Shell does not see the awkward names and therefore cannot confuse the situation.

Last edited by methyl; 08-12-2012 at 02:25 AM.. Reason: Multiple typos and enhancements.
This User Gave Thanks to methyl For This Post:
# 9  
Old 08-12-2012
Quote:
Originally Posted by methyl
@nixie
1) Post #1 was the worst formatted post I have seen in months.
Sorry that was my very first post.
Quote:
Originally Posted by methyl
@nixie
2) Please use code tags when posting code or data.
Every single option when referring to options on a long command???
Quote:
Originally Posted by methyl
@nixie
3) Please avoid punctuating code with English punctuation - particularly quotes. It makes the code read like nonsense.
It wasn't code... it was a diagnostic message issued by awk copied and pasted from the terminal window. Some of the things marked above are
awk options not a complete statement. Are you saying you want every tiny fragment put in CODE tags as was done above?
Quote:
Originally Posted by methyl
@nixie
4) Please do not a use Microsoft character set when posting unix code. Copy/paste via Windows Notepad to get rid of weird characters which have no meaning in unix scripts.
I wasn't aware it was doing that, I was pasting from a plain text editor.
Quote:
Originally Posted by methyl
@nixie
5) Please mention what Operating System and version you have and what Shell you are using. There is much variation on the find command and you and @alister refer to much obscure syntax which is definitely not from a unix find.
I don't know how to determine the version of Linux, (find (GNU findutils) 4.4.2) but neither are obscure, (although I agree the options could be considered obscure) they are from a very current version of CentOS, which is being run by a major web hosting company (AFAIK many of the major shared hosts use this OS).

---------- Post updated at 11:36 AM ---------- Previous update was at 10:40 AM ----------

Quote:
Originally Posted by methyl
See man find for your system (whatever that is?). If it is not there, just use \; as usual. The + can be faster on certain Operating System (e.g. modern Solaris).
Thanks for this - I saw this \; sequence on the original code that I got the statement from, but it was using \ to break the statement up into multiple lines. I thought \; was a an artifact left over from editing (having the meaning of "null/empty line"). I couldn't find \; in the man pages - I went back and checked again and found + which appears to be the preferred syntax. Find is very powerful, but I find it very hard to grok - been programming for 35 years, but very new to shell scripting. I don't do enough bash scripting to keep sharp with the syntax, so I have to look almost everything up as I go so I really appreciate when the gurus here can look at a statement and give a quick pointer or hint. Smilie

Quote:
Originally Posted by methyl
Apache is a package which you can install on unix of Linux. Whether it be unix of Linux, the Operating System will support space characters in filenames.

The sentence supplement containing "MD5" makes no sense whatsoever to me.

"Escape Sequences" are usually associated with driving special effects on Printers and VDUs. What do you mean?
Sorry maybe I should have said escaping?? i.e. preceeding with \ to ignore the special meaning of the next character or include a character like a blank or quote.

Quote:
Originally Posted by methyl
Please provide examples of awkward directory names which you wish to exclude (blotting anything confidential with X's).
When the list gets awkward the best approach is to use sed with a sedfile to eliminate unwanted file or directory names. Using a sedfile means that the Shell does not see the awkward names and therefore cannot confuse the situation.
I am running this script in the home directory of a shared host. AFAIK whitespace is not allowed in URL's (filenames in public_html) I certainly don't use whitespace in these names. I'm also not expecting to see them in the files of open source packages like wordpress, drupal, etc. Is module with whitespace.class.php even legal? AFAIK it isn't, and my current belief is that no good programmer would do it.

Am I naive in these assumptions? I didn't expect to find these, so I didn't design the script with that in mind, but after your post I did a test and the line of code in question did work correctly even on a filename with a space in it.
# 10  
Old 08-12-2012
The code tags thing is so everyone can see significant space characters in commands or messages. It is much easier to read a post if code is separated from comment. It is not necessary to put every code fragment in code tags but it can reduce ambiguty when the command is an English word (like "find").

I too do not like space characters in file names or URLs, though I believe that the are valid in both circumstances. When in an URL, a space character is represented by %20.
This User Gave Thanks to methyl For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

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

3. Solaris

Flarcreate and excluding directories with software installed

Got a solaris 10 server that I want to take a flar of in order to use to build a new server. Works fine. Only trouble is there is software on the original server that is not needed on the new server - it will be uninstalled. I was thinking of creating the flar from the original server and... (0 Replies)
Discussion started by: psychocandy
0 Replies

4. Shell Programming and Scripting

Copy files/directories excluding multiple paterns

my directory structure is like below: basedir\ p.txt q.htm r.java b\ abc.htm xyz.java c\ p.htm q.java rst.txt my requirement is i want to copy all the files and directories... (0 Replies)
Discussion started by: ajayyadavmca
0 Replies

5. UNIX for Dummies Questions & Answers

List directories and sub directories recursively excluding files

Hi, Please help me, how to get all the direcotries, its sub directories and its sub directories recursively, need to exclude all the files in the process. I wanted to disply using a unix command all the directories recursively excluding files. I tried 'ls -FR' but that display files as... (3 Replies)
Discussion started by: pointers
3 Replies

6. UNIX for Dummies Questions & Answers

Copy Directories excluding files

Hi guys, I want to copy folder and sub folders only. I don't want the files. If i use cp -r command it will copy entirely with files. Could any one suggest me. Thanks in advance (1 Reply)
Discussion started by: karthik82
1 Replies

7. UNIX for Dummies Questions & Answers

Excluding directories with find

How do I exclude directories with the find command on Solaris? I want to skip the directories /proc and /shared. find / -nouser -print This shows me all files and directories that don't have an owner but I need to skip /shared and /proc. I've been able to get it to work on Linux... (3 Replies)
Discussion started by: x96riley3
3 Replies

8. Shell Programming and Scripting

cp -r excluding certain directories?

I want to recursively copy /home/me/someProject/* to a /home/you/ but I want to exclude directories called "classes". I can't find any option for excluding certain directories. Does such a thing exist, or any workaround, or am I missing something obvious> (2 Replies)
Discussion started by: sarnobat
2 Replies

9. Shell Programming and Scripting

excluding directories in tar

In a bash script I am writing I am having a problem excluding selected directories from tar. From the machine $SERVER I issue the command #start netcat on storage server gnetcat -l -vv -p 2011 >$FILEPATH/$SHORT_NAME.$today.tar & The the following command is then sent to the $CLIENT. #start... (2 Replies)
Discussion started by: thumper
2 Replies

10. UNIX for Dummies Questions & Answers

excluding directories while using tar

How do I exclude some directories while creating a tar file with a number of directories? thanks. (2 Replies)
Discussion started by: uchachra
2 Replies
Login or Register to Ask a Question