- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- 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
Discussions
Discussions
Forums
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
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