This is a discussion on find command and excluding files under specific directories within the AIX Operating System forums, part of the Unix Operating Systems category; --> Help with find and excluding files under specific directories. For these specific dirs, I want to exclude all files ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Help with find and excluding files under specific directories. For these specific dirs, I want to exclude all files under, but keep the directory names. /opt/2004/jan /opt/2004/feb/logs /opt/2004/mar/outs Could someone please tell me the correct syntax I should use for my find command? And don't tell me to read the man pages, because I've done that! Cheers! |
| |||
| shpot4@yahoo.com wrote: >>> Help with find and excluding files under specific directories. >>> For these specific dirs, I want to exclude all files under, but keep >>> the directory names. >> >> find /opt/2004 -type d -print > > That will exclude the entire directory /opt/2004 and everything under > it. I need to keep the directory structure, and remove files "under". First, please keep some of what you are referring to when replying! It makes reading so much easier. Second, That will NOT exclude the entire directory /opt/2004. Did you try it? Maybe the response was not what you needed, but it is hard to tell as you do not make yourself clear: - What exactly do you want to find? - What are 'specific directories'? - Is a directory a file? If you cannot explain it, maybe you can provide an example (before/after) detailed enough so we can guess what you want. Yours, Laurenz Albe |
| |||
| shpot4@yahoo.com wrote: > Help with find and excluding files under specific directories. > For these specific dirs, I want to exclude all files under, but keep > the directory names. > > /opt/2004/jan > /opt/2004/feb/logs > /opt/2004/mar/outs > > Could someone please tell me the correct syntax I should use for my > find command? And don't tell me to read the man pages, because I've > done that! > > Cheers! read man pages concentrate on -type f and the -prune options |
| |||
| A simple way is find /opt | egrep -v '/opt/(jan|feb/logs|mar/outs)/' But it uses two commands and a pipe sigh! OBS: the trailing / does mots of the job ... > shpot4@yahoo.com wrote: > > > Help with find and excluding files under specific directories. > > For these specific dirs, I want to exclude all files under, but keep > > the directory names. > > > > /opt/2004/jan > > /opt/2004/feb/logs > > /opt/2004/mar/outs > > > > Could someone please tell me the correct syntax I should use for my > > find command? And don't tell me to read the man pages, because I've > > done that! > > > > Cheers! |