- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- use "find" command
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
10-07-2007 06:12 PM
10-07-2007 06:12 PM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2007 06:25 PM
10-07-2007 06:25 PM
Re: use "find" command
$ find . -mtime +10 -exec magic_script +
And in the script:
#!/usr/bin/ksh
for file in $*; do
mv $file /tmp
base=$(basename $file)
gzip /tmp/$base
done
Note if there are directory levels in your source directory, you would flatten them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2007 07:38 PM
10-07-2007 07:38 PM
Re: use "find" command
if it possible to do it with only ONE "find" statement ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2007 02:09 AM
10-08-2007 02:09 AM
Solution> "find" statement ?
I see only one "find" command in that
suggestion. Or did you mean one "find"
command without the "magic_script"?
"find" is a useful program, but if you wish
to do any complex tasks with it, it's often
much simpler to use a "magic_script" instead
of trying to find a way to put anything even
slightly complex into a "find" command line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2007 02:17 AM
10-08-2007 02:17 AM
Re: use "find" command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2007 01:49 PM
10-08-2007 01:49 PM
Re: use "find" command
Yes , I mean to write one "find" command without the "magic_script" , that mean have two action after -exec , is it OK ?
thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2007 02:46 PM
10-08-2007 02:46 PM
Re: use "find" command
As Steve and I have said, it isn't worth it to strain your brain and write unmaintainable code to do that. You can only do one thing in each -exec. Having the script just makes it easier.
And with -exec ... +, there is no need to worry about performance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2007 02:50 PM
10-08-2007 02:50 PM
Re: use "find" command
> "magic_script" , that mean have two action
> after -exec , is it OK ?
You can have more than one "-exec" option,
and that can give you more than one action,
but all kinds of non-simple things which you
might wish to do won't work. For example:
dy # find . -name y.c -exec echo {} \; -exec echo /tmp/{} \;
./y.c
/tmp/{}
On a "find" command line, "{}" must be a
"command argument", that is, a token on the
command line, not _part_ of a token on the
command line.
In a shell script (like "magic_script"), you
can use an expression like "/tmp/$1", and
everyone will be happy. Perhaps you can find
a way to do what you want with a complicated
"find" command, but in many (most?) cases,
it will be _much_ easier to use a separate
script to do anything which is not simple.
Why is it so important to do this job the
hard way?