Date: Sat, 25 Jul 2020 23:29:21 +0200 From: Polytropon <freebsd@edvax.de> To: Lonnie Cumberland <lonnie@outstep.com> Cc: freebsd-questions@freebsd.org Subject: Re: tbz file from pkg Message-ID: <20200725232921.be0dd463.freebsd@edvax.de> In-Reply-To: <CAPmsJLAYACVmXF%2BpzeBosP8AT8n8ewY7%2BDGtHeSezB_8EP2zBg@mail.gmail.com> References: <CAPmsJLC0yTtek8AKo6r_XL8yt_9dCNvGs1jyVyOTu6g9N7YziA@mail.gmail.com> <20200725203801.9a4965b8.freebsd@edvax.de> <CAPmsJLAdK-1aS8r6=oB253ooZyaL2Q6GMNG-sAJBdR_KEXoGRg@mail.gmail.com> <CAPmsJLAYACVmXF%2BpzeBosP8AT8n8ewY7%2BDGtHeSezB_8EP2zBg@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 25 Jul 2020 17:15:53 -0400, Lonnie Cumberland wrote: > Hi All, > > I find that I do not need a fully blown shell script, so I cobbled together > a single set of shell commands that will convert "*.txz" file to "*.tbz" > files and it seems to work. > > # find *txz -iname '*txz' | while read txz; do echo "Found: $txz"; > name=$(echo "$txz" | sed -e 's/\.[^.]*$//'); mkdir -p tmp/$name; tar -xjf > $txz -C tmp/$name; cd tmp/$name; tar cvfj ../../$name.tbz .; cd ../..; rm > -Rf tmp/$name; rm -Rf tmp; done > > maybe it will be of help to others as well. Allow me a little addition: The first parameter to find should be a directory. If you are already in the directory where the files are stored, use ".". Note that using -iname will also process *.Txz or *.TXZ, if that is desired. If you want to remove the extension, you don't need to use sed for this: The shell - I assume it is sh - can do this for you: For example, if txz="foo-1.2.3_4,5.txz", then ${txz%.*} or ${txz%.txz} will be "foo-1.2.3_4,5". See section "Parameter Expansion" in "man 1 sh" for details. :-) Another suggestion would maybe be to omit the "store, repackage, delete" step and use a pipe. Maybe it would also be possible to omit the "extract" part altogether: Have xz only decompress (result is a regular tar file), then bzip2 recompress, that could also be possible without a temporary file if you can use |. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200725232921.be0dd463.freebsd>