- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Tar and 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
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
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
тАО03-12-2009 08:50 AM
тАО03-12-2009 08:50 AM
command from hpserv01: tar -cvf ./testdev_duts.tar `find /net/hpserv02/LTX/hp_testdev_duts/ -mtime +1000`
any help would be greatly appreciated.
Thanks,
Phil
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 09:10 AM
тАО03-12-2009 09:10 AM
Re: Tar and find command
Try this:
# find /net/hpserv02/LTX/hp_testdev_duts/ -mtime +1000 | xargs tar -cvf ./testdev_duts.tar
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 09:26 AM
тАО03-12-2009 09:26 AM
Re: Tar and find command
I would do a mv command but afraid I will loose my data and screw things up.
Any ideas ?
Thanks,
phil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 09:35 AM
тАО03-12-2009 09:35 AM
SolutionWith 'tar' you should create archives with _relative_ paths instead of absolute ones unless (1) you want to "go nuts"; or (2) use 'pax' to strip the leading '/' to make a relative path.
That said, change you find to output relative paths:
# cd /path
# find . -mtime +1000
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 09:50 AM
тАО03-12-2009 09:50 AM
Re: Tar and find command
Thanks.
Phil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 10:43 AM
тАО03-12-2009 10:43 AM
Re: Tar and find command
find /net/hpserv02/LTX/hp_testdev_duts/ -mtime +1000 | tar -cvf - | ssh hpserv02 "(cd /some/dir; tar xf -)'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 10:43 AM
тАО03-12-2009 10:43 AM
Re: Tar and find command
find /net/hpserv02/LTX/hp_testdev_duts/ -mtime +1000 | tar -cvf - | ssh hpserv02 "(cd /some/dir; tar xf -)"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 10:48 AM
тАО03-12-2009 10:48 AM
Re: Tar and find command
You can't really use find and tar for large amounts of files, don't even try. Instead use cpio or pax(1). Both of these take their files from stdin:
find /net/hpserv02/LTX/hp_testdev_duts/ -mtime +1000 | \
pax -w -f ./testdev_duts.tar
pax also allows you to to rename the files when you extract so you don't have to cd into the directory root, as JRF suggested.
>JRF: find ... | xargs tar -cvf ./testdev_duts.tar
This will fail since it will overwrite the tarfile over and over.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 10:56 AM
тАО03-12-2009 10:56 AM
Re: Tar and find command
Ah, oops. Good catch, Dennis. You are correct, the 'find ... | xargs ...' will indeed _overwrite_.
Phil, compare a test case like this where there are a relatively few files:
# find /tmp -type f -mtime -7|xargs tar -cvf /var/tmp/MYTHING
# tar -tvf /tmp/MYTHING
...versus:
# find /tmp -type f -mtime -7|xargs -l2 tar -cvf /var/tmp/MYTHING
# # tar -tvf /tmp/MYTHING
...which takes two (2) arguments at a time. This demonstates the problem Dennis cited.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 10:56 AM
тАО03-12-2009 10:56 AM
Re: Tar and find command
Thanks,
phil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 11:05 AM
тАО03-12-2009 11:05 AM
Re: Tar and find command
If the command is there on one, it should be on all.
>it finished it only had the last directory in it.
I assumed you were happy because JRF's cd approach would reduce the length of the command line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 11:08 AM
тАО03-12-2009 11:08 AM
Re: Tar and find command
Yes, 'pax' exists on 10.20 :
http://docs.hp.com/en/B2355-90128/pax.1.html
Another alternative is to install the GNU tar which allows '├в --files-from=file-name├в which is designed to read a list of filenames contained in a file as you would generate from a 'find' command.
You can fetch GNU tar from here:
http://hpux.connect.org.uk/hppd/hpux/Gnu/tar-1.20/
...though for 10.20, you will have to compile it yourself
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-13-2009 04:57 AM
тАО03-13-2009 04:57 AM
Re: Tar and find command
tar zcvf test.tar $(find /net/hpserv02/LTX/hp_testdev_duts/ -mtime +1000)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-13-2009 04:59 AM
тАО03-13-2009 04:59 AM
Re: Tar and find command
The pax command did the trick. did not even know about that command.
Phil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-13-2009 07:57 AM
тАО03-13-2009 07:57 AM
Re: Tar and find command
> [...]
Or, if you'd like a method which _won't_
produce a too-long command line, GNU "tar"
has a "--files-from=file-name"
("-T=file-name") option, and "file-name" can
be "-" (stdin), so you could pipe the "find"
output into it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-13-2009 08:10 AM
тАО03-13-2009 08:10 AM
Re: Tar and find command
>>tar zcvf test.tar $(find /net/hpserv02/LTX/hp_testdev_duts/ -mtime +1000)
This may be fine on Linux, or with GNU tar, but with the HP-UX native tar the '-z' option (to create a gzip'ed tar file) is not valid.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-13-2009 08:46 AM
тАО03-13-2009 08:46 AM
Re: Tar and find command
Yeah we could do:
tar cvf test.tar $(find /net/hpserv02/LTX/hp_testdev_duts/ -mtime +1000) && gzip test.tar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-13-2009 10:23 AM
тАО03-13-2009 10:23 AM
Re: Tar and find command
> [...]
Or, we could learn something, and avoid the
problem of the too-long command line, and
also avoid the temporary file. (HP-UX shells
_do_ know how to deal with pipelines.)