I’m looking for a way to add the utility “unar” to my available commands / tools in TrueNAS SCALE - is there a way to download / install it in such a way that it will persist across OS updates?
Only if iX decides to add it. They did this for 7zip after this feature request. I guess that makes adding another compression tool unlikely,
[Accepted] Add unrar / 7zip to Truenas Scale.
I guess you could add it in dev mode, but that is highly discouraged and won’t survive a OS update.
The 7zip package also supports RAR archives.
Hm, OK. Let me back up and give a better idea of what I am trying to accomplish, I think I asked the wrong question.
I have a series of ZIp files (foo1.zip, foo2.zip foo3.zip) in a directory. I’d like to run a simple command that will unzip each one into its own sub-folder: ./foo1, ./foo2, ./foo3, etc.
When I googled this up, “unar -d” seemed to do the trick with minimal arguments. Looking up 7zip, I can’t tell if it has this simple of a functionality, or it needs more specific arguments.
I think I found my solultion:
A simple one-liner with 7z
looks like this:
for i in *.zip; do 7z x $i -o$(basename $i .zip); done
This works in Core (FreeBSD) with the bash
shell.
It should work for SCALE (Linux).
Oh yeah, that thread. …forum user tip. Do not try and talk about security implications (especially if they are “yet to be announced”) unless you want to be called a troll and/or banned.
use find instead. # man find | less /+EXAMPLES
yeah, like those examples. nice find.
find
works, but the OP made it sound like a bunch of files inside the same folder. No need to traverse any deeper.
Either way, -o
with the use of a variable will extract the contents into a new subdirectory.
Directory traversial was not the reason I recommended using find. Neither was trying to replicate the 7z -o switch.
I’m not sure what you want me to say. …If you want directory traversal information:
man find | less +/maxdepth
Whatever you want to say? I think there’s a loss in translation somewhere.
You people do what you want, but find
is better for
is dangerous (or should be kept in shell scripts and you know what you’re doing). You operate unix/linx with pipes, lists and stuff. The find util is easier and better for experienced users and new users in the long run [learn the proper way]. …Take the example of how to go about updating a *nix system.
bsd example; you may prefer a different flavor:
# pkg prime-origins > ~/prime.list
# do stuff
# do pkg del
# pkg install `cat ~/prime.list`
Back to find (read: “the lists”) methodology… Here’s a list (because that’s a directory I’m in, at the moment; choose your own flavor for this too):
find "${@:-.}" -name "*.c" -not -name . -print
find offers a ton of switches you can use to “build a list” like “size” “date” and etc. Lists and pipes are used for simple things like this and more complicated things like updating your system (not that updating a BSD system is difficult-i.e., there isn’t very many more lines needed to my example above).