- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- using tar with xargs
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
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
тАО08-23-2002 09:07 AM
тАО08-23-2002 09:07 AM
I'm trying to tar a big number of files in a directory(I know it's not a good practice to have so many files in a single directory), to avoid the "arg line too longs..." error, I'm going to use xargs with tar, like
$ ls | xargs tar cvf myarc.tar
xargs will break all files into small sets and feed to tar for several times, but the problem is, it seemed that the latest invoke of tar always over write the tar file generated of last time, and finally I got the "myarc.tar" file with only the last set of files, is there any work around here ?
thanks,
Gary
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2002 09:14 AM
тАО08-23-2002 09:14 AM
Re: using tar with xargs
I'm confused?
why not
tar -cvf myarc.tar .
??
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2002 09:14 AM
тАО08-23-2002 09:14 AM
Re: using tar with xargs
Specify a non-rewind tape device, explicitly as the destination (e.g. /dev/rmt/omn) or use the '-r' option of 'tar' to append to the archive. See the man pages for more information.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2002 09:15 AM
тАО08-23-2002 09:15 AM
Re: using tar with xargs
tar cvf /mydir/myarc.tar .
One tar and tar does all the argument expansion for you via the . to tar the current directory (and any subdirs).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2002 09:16 AM
тАО08-23-2002 09:16 AM
Re: using tar with xargs
If you have a list of files to copy you can use "cpio". If you want to tar all files is a directory, you can do-
cd directory
tar cvf myarc.tar .
hope this helps.
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2002 09:28 AM
тАО08-23-2002 09:28 AM
Re: using tar with xargs
you could try the *key* "r" (rewrite) instead of "c" (create).
Just my $0.02,
Wodisch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2002 09:34 AM
тАО08-23-2002 09:34 AM
Re: using tar with xargs
I agree with Wodisch.
touch /other_dir/myarc.tar
then
ls | xargs tar rvf /other_dir/myarc.tar
You need to add them to the archive - not create a new archive every pass.
Also you should tar them into another directory or you'll get a recursive tar file.
Rgds,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2002 09:49 AM
тАО08-23-2002 09:49 AM
Solutiontar doesn't allow the "r" option (which appends files to the end of a tar) if the tar doesn't already exist. So if you don't mind getting a duplicate file in your archive (maybe some junk file called "hello" that contains the word "hello") do the following.
Put this file "hello" in the directory you plan to tar.
cd to the directory. Run the following two commands in sequence:
ls | xargs -i tar cf myTar.tar
then:
ls | xargs -i tar rf myTar.tar
I tested this and it worked perfectly. You could also do this to a tape.
You'll wind up with a double copy of the "hello" file, but it'll just overwrite itself when you extract anyway.
Hope this helps.
- Allan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2002 09:52 AM
тАО08-23-2002 09:52 AM
Re: using tar with xargs
Yes, '-r' with tar does the work, but fyi Jeff, I did try "touch arch.tar" to create a tar file to use '-r', but tar complained about the file format :
Tar: blocksize = 0; broken pipe?
so I have to create a dummy file and make it into tar file.
I also learned that '.' with tar can also expand all the files ...
thank you all again.
Gary
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2002 09:57 AM
тАО08-23-2002 09:57 AM
Re: using tar with xargs
OOPS!!!
I missed something in my commands. Do the following two commands:
ls hello | xargs -i tar cf myTar.tar {}
then:
ls | xargs -i tar rf myTar.tar {}
That'll do it!!!!
- Allan