- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- find problem
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-11-2006 08:34 AM
тАО07-11-2006 08:34 AM
find problem
from /log to /log/bak
Which piece am I missing here :
find /log -type f -name "*.gz" -mtime -1 -exec mv{} /log/bak
Also once they are moved the log files to /log/bak I have recreate them in order to record the logs :
is this a gud way :
for files in /log
do
touch $i
done
Can there be a better way here.
Thx!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2006 08:37 AM
тАО07-11-2006 08:37 AM
Re: find problem
find /log -type f -name "*.gz" -mtime -1 -exec mv{} /log/bak \;
Think your only missing the \; piece to it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2006 08:39 AM
тАО07-11-2006 08:39 AM
Re: find problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2006 08:43 AM
тАО07-11-2006 08:43 AM
Re: find problem
Heres how I tested it:
servera:root /home/dahmin/dahtemp # ll
total 16
drwxr-xr-x 2 root sys 96 Jul 11 15:50 .
drwxr-xr-x 4 dahmin users 8192 Jul 11 15:51 ..
-rw-r--r-- 1 root sys 0 Jul 11 15:50 dahtest
servera:root /home/dahmin/dahtemp # cd ..
servera:root /home/dahmin # ll
total 176
drwxr-xr-x 4 dahmin users 8192 Jul 11 15:51 .
drwxr-xr-x 13 root root 8192 Jun 14 12:08 ..
-rw------- 1 dahmin users 0 Sep 30 2005 .ICEauthority
-rw------- 1 dahmin users 73 Sep 30 2005 .TTauthority
-rw------- 1 dahmin users 49 Sep 30 2005 .Xauthority
-r--r--r-- 1 dahmin users 814 Nov 7 1997 .cshrc
drwxr-xr-x 11 dahmin users 8192 Sep 30 2005 .dt
-rwxr-xr-x 1 dahmin users 5451 Sep 30 2005 .dtprofile
-r--r--r-- 1 dahmin users 347 Oct 27 1997 .exrc
-r--r--r-- 1 dahmin users 341 Nov 7 1997 .login
-rw-r--r-- 1 dahmin users 446 Sep 21 2005 .profile
-rw------- 1 dahmin users 1906 Jul 10 10:24 .sh_history
drwxr-xr-x 2 root sys 96 Jul 11 15:50 dahtemp
-rw-r--r-- 1 root sys 0 Jul 11 15:51 davefile
servera:root /home/dahmin # find . -name *davefile* -exec mv {} ./dahtemp \;
servera:root /home/dahmin # cd dahtemp
servera:root /home/dahmin/dahtemp # ll
total 16
drwxr-xr-x 2 root sys 96 Jul 11 15:52 .
drwxr-xr-x 4 dahmin users 8192 Jul 11 15:52 ..
-rw-r--r-- 1 root sys 0 Jul 11 15:50 dahtest
-rw-r--r-- 1 root sys 0 Jul 11 15:51 davefile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2006 08:50 AM
тАО07-11-2006 08:50 AM
Re: find problem
find /log -type f -name "*.gz" -mtime -1 >/tmp/filelist
for file in `cat /tmp/filelist`
do
mv $file /log/bak
done
Hope it helps`
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2006 08:51 AM
тАО07-11-2006 08:51 AM
Re: find problem
if your source files are in /log and your destination is in /log/bak, then the find command you list will also find the files in your destination directory, and either create errors or worse, destroy the files when it tries to move them into the same filename.
you'll want to use someting like:
find /log -type f -path "/log/*.gz" \
-mtime -1 -exec mv {} /log/bak \;
(all on one line)
note the "-path" instead of "-name" will only find files in /log but not in subdirectories.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2006 08:51 AM
тАО07-11-2006 08:51 AM
Re: find problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2006 08:55 AM
тАО07-11-2006 08:55 AM
Re: find problem
Your original post:
# find /log -type f -name "*.gz" -mtime -1 -exec mv{} /log/bak
...has *no* whitespace between 'mv' and the opening curly brace. It needs that! :
find /log -type f -name "*.gz" -mtime -1 -exec mv {} /log/bak
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2006 08:58 AM
тАО07-11-2006 08:58 AM