- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Find command - directory & file selection
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2002 02:52 AM
07-18-2002 02:52 AM
I have an archive directory containing several subdirectories, one of which is called "secure". I need to compress all files in all the subdirs (using compress -f or compressdir -f) EXCEPT the files in "secure" - they may be needed at an instant's notice. Your help would be much appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2002 02:57 AM
07-18-2002 02:57 AM
Re: Find command - directory & file selection
the following command should do it for you:
find /path/to/directory -type d -print | grep -v 'secure' | compressdir -f
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2002 03:27 AM
07-18-2002 03:27 AM
Re: Find command - directory & file selection
That worked OK as it stood, but then I started experimenting. I tried to identify a single directory for compression using:
find . -type d | grep pioneer | compressdir -f
(where pioneer is another of the sub-dirs) and every single sub-dir in the archive directory was compressed; the grep seems to have been ignored.
My original intention was to include in a log a count of the files to be compressed (i.e. everything not ending in .Z), which I did with:
UnCompFiles=$(find . -type f -name "*[!Z]" -print | wc -l)
Unfortunately, that includes the files in the secure sub-dir. If possible, I'd like to know how to find uncompressed files in all archive sub-dirs except the secure sub-dir. A pint of warm, flat British beer to the first correct answer!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2002 03:37 AM
07-18-2002 03:37 AM
Re: Find command - directory & file selection
Scratch part of my last message - I missed out the "-print" from my find. It now identifies the pioneer directory accurately, but compressdir -f doesn't work properly; it doesn't compress empty files, a requirement of mine.
So it now looks as though my definitive question is: how do I identify uncompressed files in sub-dirs other than secure so that I can compress them using compress -f?
Thanks again,
Kevin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2002 03:37 AM
07-18-2002 03:37 AM
Re: Find command - directory & file selection
you want to know the number of all files which where compressed, but no files to be compressed which are under subdirectory secure?
Here we go.....
var=`find /path -type d -print | grep -v 'secure' | ls -Al | wc -l`
That should do it for you....
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2002 03:39 AM
07-18-2002 03:39 AM
Re: Find command - directory & file selection
UnCompFiles=$(find . -type f -name "*[!Z]" -print |grep -v /secure/| wc -l)
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2002 03:46 AM
07-18-2002 03:46 AM
Re: Find command - directory & file selection
sorry for my last posting, there is a little error in it:
ls -Al --> output are "allmost" all entries, without "." and "..", but also a header line, named "total" and then the number of blocks of directory. Either you forget the -l option or you include the command "grep -v total" before the command "wc -l"
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2002 04:02 AM
07-18-2002 04:02 AM
Re: Find command - directory & file selection
You've both been incredibly helpful, so thank you for your kind patience. Warm British beers all round!
Your answers to stripping out the "secure" sub-dir both involve piping find's output to grep; what I'm really trying to get to here is how to use *only* the find command. That way, I can use the -exec primary to call compress -f as mentioned in an earlier posting. I've been experimenting with the -path, -prune and -only primaries but haven't been successful.
A juicy 10 points to whoever shows me how to read the sub-dirs as I'd like, using only find's primaries :-)
Honest - this'll be my last question for a while!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2002 04:16 AM
07-18-2002 04:16 AM
Re: Find command - directory & file selection
You may wish to leave off the compressdir -f whilst you're experimenting so you can just see the list of directories that will be passed to compressdir.
To answer your query about counting the files, you need to filter out any files which have 'secure' in the returned path. I'd suggest changing your line to:
UnCompFiles=$(find . -type f
-name "*[!Z]" -print | grep -v 'secure' | wc -l)
If an individual file is likely to contain the word secure then it might be better to include the trailing slash after secure in the grep statement.
regards,
Darren.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2002 04:17 AM
07-18-2002 04:17 AM
Re: Find command - directory & file selection
just another ??? 0.02
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2002 04:31 AM
07-18-2002 04:31 AM
Solutioni just had a closer look to the man page of the find- command. Brrrrrrrr....
In my opinion it's not possible to solve the problem using only the find command because you don't get rid of the subdirectory "secure". But for the reason our solutions worked, why think over a problem that is no longer existant? Pipelining is very often the only way to get something to work, we should be glad to have such a powerful tool.
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2002 04:50 AM
07-18-2002 04:50 AM
Re: Find command - directory & file selection
cd
DIRS=`ls -p|grep /|grep -v secure`
for DIR in $DIRS
do
compressdir -f $DIR
done
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2002 05:23 AM
07-18-2002 05:23 AM
Re: Find command - directory & file selection
First of all, thank you all for your kind help and interest in my wee problem. I was heartened to receive such patient attention and so many solutions.
I'm sure you'll be pleasantly surprised to hear that I found the find-only solution I was looking for:
find . -type -f ! -name "*.Z" ! -path "./secure/*" -exec compress -f {} \;
In any case, I've learned a lot today - thank you again.
TTFN from bonnie Edinburgh.
In the words of Young Mr. Grace: "You've all done very well!"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2002 05:25 AM
07-18-2002 05:25 AM
Re: Find command - directory & file selection
An additional hyphen crept in. Last posting should have read:
find . -type f ! -name "*.Z" ! -path "./secure/*" -exec compress -f {} \;
Regards,
Kevin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2002 05:37 AM
07-18-2002 05:37 AM
Re: Find command - directory & file selection
thank you! Now i learned something new.... Negation with the find- command! :-)
no points for this please
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2002 05:51 AM
07-18-2002 05:51 AM
Re: Find command - directory & file selection
http://hpux.cs.utah.edu/hppd/hpux/Gnu/findutils-4.1.5/