- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- backup files modified in the last 7 days
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
тАО12-04-2007 03:23 AM
тАО12-04-2007 03:23 AM
I have a scenario whereby a customer wants to generate a tar file of all files modified in the last 7 days. I thought this would be quite simple. I created a dummy tar file then ran:-
I ran find /noddy -type f -mtime -7 | xargs tar -rf /tmp/dummy.tar
This appeared to work fine then I noticed a lot of errors due to files with strange file naming conventions that its saying it effectively could not find. Is there a better way of doing this?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2007 03:34 AM
тАО12-04-2007 03:34 AM
Re: backup files modified in the last 7 days
can you post the exact error messages?
It could be that you do not have enough permissions to access some of the files in the /noddy directory.
revert
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2007 04:56 AM
тАО12-04-2007 04:56 AM
Re: backup files modified in the last 7 days
/tmp/dummy.tar?
that will cause that you potentialy are edding files to a tar file whit the same name, I guess that can gave strange errors!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2007 04:59 AM
тАО12-04-2007 04:59 AM
SolutionWith GNU tools, the way to handle complex filenames safely in commands like this is to use the "-print0" option of GNU find and the "-0" option of GNU xargs.
HP-UX has the same functionality implemented in a different way: the HP-UX find has the "-exec
Try a command like
find /noddy -type f -mtime -7 -exec tar -rf /tmp/dummy.tar {} \+
This should be as efficient as the find+xargs combination, but capable of handling filenames with spaces and/or all kinds of special characters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2007 05:01 AM
тАО12-04-2007 05:01 AM
Re: backup files modified in the last 7 days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2007 05:02 AM
тАО12-04-2007 05:02 AM
Re: backup files modified in the last 7 days
[nlxsms01:root:/home/nl11588]# find ./joke | xargs tar -rf /tmp/dummy.tar
[nlxsms01:root:/home/nl11588]# find ./joke | xargs tar -rf /tmp/dummy.tar
[nlxsms01:root:/home/nl11588]# find ./joke | xargs tar -rf /tmp/dummy.tar
[nlxsms01:root:/home/nl11588]# tar -tvf /tmp/dummy.tar
rwxr-x--- 18588/10000 0 Dec 3 12:48 2007 ./joke/
rwxr-x--- 18588/10000 0 Dec 3 12:48 2007 ./joke/
rwxr-x--- 18588/10000 0 Dec 3 12:48 2007 ./joke/
rwxr-x--- 18588/10000 0 Dec 3 12:48 2007 ./joke/
rwxr-x--- 18588/10000 0 Dec 3 12:48 2007 ./joke/
rwxr-x--- 18588/10000 0 Dec 4 13:59 2007 ./joke/
rw-r--r-- 0/3 0 Dec 4 13:59 2007 ./joke/1
rw-r--r-- 0/3 0 Dec 4 13:59 2007 ./joke/2
rw-r--r-- 0/3 0 Dec 4 13:59 2007 ./joke/1
rw-r--r-- 0/3 0 Dec 4 13:59 2007 ./joke/2
rwxr-x--- 18588/10000 0 Dec 4 13:59 2007 ./joke/
rw-r--r-- 0/3 0 Dec 4 13:59 2007 ./joke/1
rw-r--r-- 0/3 0 Dec 4 13:59 2007 ./joke/2
rw-r--r-- 0/3 0 Dec 4 13:59 2007 ./joke/1
rw-r--r-- 0/3 0 Dec 4 13:59 2007 ./joke/2
[nlxsms01:root:/home/nl11588]#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2007 06:49 PM
тАО12-04-2007 06:49 PM
Re: backup files modified in the last 7 days
You instead should use cpio, which takes the list of files from stdin, or use pax(1), which combines the best of cpio/tar:
$ find /noddy -type f -mtime -7 | pax -w -f /tmp/dummy.tar
>Matti: the combination of find+xargs is sensitive to spaces in file names.
pax(1) handles the spaces fine.