SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
So is the issue that I've been looking at tar.bz2 files for so many years that I mistakenly assumed these are tar archives when they are not, and thus fall outside the functionality of the tar program? Seems like this may be the case.
I believe those images were created with dd. They a just byte-for-byte copies of SD card contents. Ark uses libarchive internally, and libarchive can handle "raw" archive format whatever that means. Edit.Raw just means compressed data without any archive structure.
This also means that bsdtar, which also uses libarchive, may be able to handle those archives as well.
In general tar should automatically detect bzip2 format and also you can use -j to [un]compress.
So it was not the usual case.
Anyway, if your problem solved please mark the thread solved.
Compressed archives are recognised automatically, it is no longer necessary to specify -Z, -z, or -j options to read them. Thus, you can now run tar tf archive.tar.gz and expect it to work!
This doesn't always work, but usually does. If you are piping into tar, you need to manually specify the archive type and it seems that OP found another exception to the rule.
You don't pass a file name when you read contents of an archive from standard input so it obviously doesn't work.
And OP has not found "exception to the rule" but uses tar on non-tar files so in other words they don't know what they're doing.
Anyway, there is no need to remember what programs you should use to extract a given archive file and with what parameters, just create `ext' function that looks like that:
Code:
$ type ext
ext is a function
ext ()
{
if [ -f "$1" ]; then
case "$1" in
*.tar.bz2)
tar xvjf "$1"
;;
*.tar.gz)
tar xvzf "$1"
;;
*.tar.xz)
tar Jxvf $1
;;
*.bz2)
bunzip2 "$1"
;;
*.rar)
unrar x "$1"
;;
*.gz)
gunzip "$1"
;;
*.tar)
tar xvf "$1"
;;
*.tbz2)
tar xvjf "$1"
;;
*.tgz)
tar xvzf "$1"
;;
*.zip)
unzip "$1"
;;
*.Z)
uncompress "$1"
;;
*.7z)
7z x "$1"
;;
*.txz)
tar Jxvf "$1"
;;
*)
echo "'$1' cannot be extracted";
return 1
;;
esac;
else
echo "'$1' is not a valid file";
return 1;
fi;
return 0
}
Last edited by average_user; 05-20-2020 at 03:11 PM.
Stating facts is hardly a personal attack, you cannot be so fragile. You use the wrong tool for the job.
And that sure is a nice way of letting OP know that "I'm better than you and you should know it".
You could've simply stated that the files were not created by tar and so tar doesn't know what to do unless you specify it, but instead you have to be a jerk about it and slam OP instead of using it as a simple teaching moment.
There once was a time when you didn't know what you were doing with tar, other aspects of computers, or life in general. You have to start somewhere. Even if someone has a ton of experience, sometimes brainfarts happen or it's just something they haven't run into. That's no reason to be rude.
I'm not saying this as someone who was offended or speculating whether or not OP was offended, but in a forum where we like to spread knowledge about Slackware and Linux, you can use some tact when presenting information that is contrary to what they originally thought.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.