LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-05-2017, 05:31 AM   #1
shams
Member
 
Registered: Jan 2004
Posts: 510

Rep: Reputation: 30
How to archive and 7z each file individually from a folder?


In ubuntu 17.04, There are many files and folders in one parent folder, how i tar and 7z each one with one command, i read and tried this one:
Code:
tar -cf | for i in *; do 7za a $i.tar.7z $i; if [ $? -eq 0 ]; then rm -rf $i; fi; done
i run this code inside the parent folder and working well, but when i want to extract the archive with this command get the error:
Code:
7za x -so stardict-babylon-Babylon_English-2.4.2.tar.7z | tar xf -
tar: Archive is compressed. Use -z option
tar: Error is not recoverable: exiting now
With gui xarchiver can extract the archive.
 
Old 06-05-2017, 06:28 AM   #2
wpeckham
Senior Member
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore, Q4OS
Posts: 3,826

Rep: Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734
Tar has options to specify the archive (or de-archive) program to use on the command line. It seems to me that using that option would be more efficient and straightforward.
 
1 members found this post helpful.
Old 06-05-2017, 06:34 AM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (current), FreeBSD, Win10, It varies
Posts: 9,952

Rep: Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148
I do not get it . did you try that "tar: Archive is compressed. Use -z option" ? and see if that unzipped the files?
 
Old 06-05-2017, 08:26 AM   #4
wpeckham
Senior Member
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore, Q4OS
Posts: 3,826

Rep: Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734
Quote:
Originally Posted by BW-userx View Post
I do not get it . did you try that "tar: Archive is compressed. Use -z option" ? and see if that unzipped the files?
The "z" option uses the gzip format. The "j" options uses the bzip2 format. There is now an "xz" option to use the XZ format.
To use 7z format will require an option to specify the 7z tools on the command line.
I believe it is I or --use-compress-program in the gnu version of tar.
 
Old 06-05-2017, 08:42 AM   #5
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (current), FreeBSD, Win10, It varies
Posts: 9,952

Rep: Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148
Quote:
Originally Posted by wpeckham View Post
The "z" option uses the gzip format. The "j" options uses the bzip2 format. There is now an "xz" option to use the XZ format.
To use 7z format will require an option to specify the 7z tools on the command line.
I believe it is I or --use-compress-program in the gnu version of tar.
not to sure how relevant this is, but it does address 7z and tar and Unix based systems.
Quote:
Limitations

The 7z format does not store filesystem permissions (such as UNIX owner/group permissions or NTFS ACLs), and hence can be inappropriate for
backup/archival purposes. A workaround on UNIX-like systems for this is to convert data to a tar bitstream before compressing with 7z. But it is worth
noting that GNU tar (common in many UNIX environments) can also compress with the LZMA algorithm natively, without the use of 7z, and that in this case
the suggested[5] file extension for the archive is ".tar.lzma" (or just ".tlz"), and not ".tar.7z". On the other hand, it is important to note, that tar
does not save the filesystem encoding, which means that tar compressed filenames can become unreadable if decompressed on a different computer. It is
also possible to use LZMA2 by running it through the xz tool. Recent versions of GNU tar support the -J switch, which runs TAR through XZ. The file extension is ".tar.xz" or ".txz". This method of compression has been adopted with many distributions for packaging, such as Arch, Debian (deb), Fedora
(rpm) and Slackware.


The 7z format does not allow extraction of some "broken files"—that is (for example) if one has the first segment of a series of 7z files, 7z cannot give
the start of the files within the archive—it must wait until all segments are downloaded. The 7z format also lacks recovery records, making it
vulnerable to data degradation. By way of comparison, zip files also lack a recovery feature. In contrast the proprietary rar format permits recoveries
as well as the extraction of broken files and file spanning.
https://en.wikipedia.org/wiki/7z
 
1 members found this post helpful.
Old 06-05-2017, 05:25 PM   #6
wpeckham
Senior Member
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore, Q4OS
Posts: 3,826

Rep: Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734Reputation: 1734
I find the last post by BW-userx pertinent and helpful.
Check your man page for tar, and make use of the native tar command-line for best results.
Note that the compression you use must be installed (or at least the required libs installed) as tar does not do the compression internally/natively. It generally calls the same compression library routines used by the command-line compression tools.


(IE: if you ahve not installed XZ then the XZ options MAY not work.)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to archive emails to a folder on my computer? grumpyskeptic Linux - Newbie 25 10-22-2016 07:03 AM
making Alpine mail client to use utf-8 while saving email archive folder file pisti Linux - Software 0 10-14-2016 03:44 AM
[SOLVED] how to archive torrent file + the iso files , like the ova archive of virtual box jheengut Linux - Software 2 12-22-2013 05:04 PM
Extracting the contents of a folder in a CPIO archive to another folder Refractor Linux - Software 4 07-10-2012 05:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration