awk is a powerful tool that is often overlooked for more familiar tools like sh,sed,grep,wc,head,tail,cat,cut,...
Quite often we can drastically speed up a command by using awk built-ins (it takes time to call external programs). I will try to show the major ones here.

That's all the time I have right now, so I will add a ...
TODO
show how to execute an external program using builtin - system() command
show how to do head/tail-like operations
show how to do math operations
show how to store variables and arrays
show how to do various loops
show how to do other stuff I am forgetting_________________Web Programming - Pet Packaging 100 & 101

explanation:
[ -f "$1" ] && tar -tvf "$1" >/tmp/tarfiles || exit
if the input is a file, get a long listing containing all of the file sizes (or exit)

tar -xvf "$1" |awk '{ ... }' /tmp/tarfiles -
go through the file /tmp/tarfiles first and then - (stdin from the tar -xvf "$1", which lists the files as they are decompressed)

if ( $3 != "" ){
size[$6]=$3
tot+=$3
if there is a size field (only in /tmp/tarfiles), then add an associative array with the file name ($6th field) as the name with the size ($3rd field) as the value, then increment the total by that amount

}else{
subtot+=size[$1]
printf "%d\n", 100 * subtot / tot
since there is no field 3, we are processing the verbose output from decompressing the tarball (each filename as it is decompressed) We use that as the name of the associative array and add its value to the subtotal, then use that subtotal to print the percentage

you can make this into a standalone script for use by yad or {,X,gtk}dialog by adding a #!/bin/sh to the top or as a function like
targress(){
#code here
}_________________Web Programming - Pet Packaging 100 & 101

It would be good if you could add a one-sentence explanation of the purpose of that targress script

Quote:

Quite often we can drastically speed up a command by using awk built-ins (it takes time to call external programs)

So you're not saying for example that an awk script is faster than a sed script, just that a single awk script is faster than a script which calls multiple tools e.g. both awk and sed. And that awk is a particularly powerful tool, so there is a good chance you can do the whole task with it. Is that right?
What about the issue that many of those tools are built in to busybox? Is awk still faster?_________________DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!

the targress code just outputs the percentage that a tarball has been extracted ... good for use in a package installer to show the user how far it has to go ... for example
targress tarball.tar | Xdialog --progress "message here" 0 0 -

using busybox is somewhat closer if you use "prefer applets" (most distros do not ... nor does Barry, due to compatibility issues) but it still has to fork /proc/self/exe for many and extra streams and pipes have to be set up ... if that is in a loop of any kind awk will win hands down, but the busybox version of awk is extremely fast and nearly as capable as gawk nawk and standard awk

awk seems difficult at first, but once you get it, its actually pretty capable of doing things that we often use several other tools for. If you can use only one tool for a task, it is often both simpler and faster (not always, my jwm_menu_create only uses busybox ash and it does a lot of stuff that would be faster/easier in awk... I just knew shell scripting better at the time)_________________Web Programming - Pet Packaging 100 & 101

Ok, here it is as something somewhat useful - a tarball extractor that _should_ work with all versions of gtkdialog (2,3,4 and the backport to gtk1)... I used Xdialog for the progress bar, since not all versions of gtkdialog have it. This could probably be extended to work for other types of archives as well by using if (FILENAME ~ ".tar")...

Thanks! It works now - I had to do slight modification as gtkdialog1 only reports the value of the first column - and it seems that gtkdialog2 tree code wont show the content so change tree to table. I havent got the gtkdialog3 to run yet.

Thanks! It works now - I had to do slight modification as gtkdialog1 only reports the value of the first column - and it seems that gtkdialog2 tree code wont show the content so change tree to table. I havent got the gtkdialog3 to run yet.
...
I had to load a kernel-pkg to actually view the progress bar - but it works very well!

good catch, I was only testing with the name ($6) & forgot to modify that when it changed, it would be nice if the first column would expand instead of the last, since it is the one that is actually used

yeah, the second part is pretty quick, but I may need to add
| tee /tmp/tarfile |
rather than pre-generating it, but I don't know if it will help - I don't think gtkdialog draws until the whole tree is loaded - I need to look into fixing that_________________Web Programming - Pet Packaging 100 & 101

The loading of the kernel pkg was rather slow...maybe also use the progress-bar when loading into gtkdialog? Or load part of the archive listing into gtkdialog - and then refresh the table when all files available? Or both...
Well - maybe this get too much off topic - sorry for that!

The loading of the kernel pkg was rather slow...maybe also use the progress-bar when loading into gtkdialog? Or load part of the archive listing into gtkdialog - and then refresh the table when all files available? Or both...
Well - maybe this get too much off topic - sorry for that!

with awk you can check how many lines to list using FNR or NR < gtkdialog_limit (what maybe 40 or so?) ... not sure the gtkdialog command to refresh or how to signal it to refresh other than just redrawing in the END section using variables after the listing is complete (I'm pretty sure the tar listing is what takes so long) ... there is no real way to do a percent bar though just an spinning hourglass (AFAIK, unless there is a way to quickly get the raw number of files in a tarball)_________________Web Programming - Pet Packaging 100 & 101

gtkdialog refresh needs a trigger from one of the widgets so it will not work...
Seems that gtkdialog1 autosize first column but gtkdialog2 does not...
Below works in gtkdialog1&2, maybe some awk-script can be used for the loading progress-bar...

@goingnuts thanks for the fixes, I guess I'll try to come up with some more examples ... probably some kind of universal daemon process that works with sit (my simple icon tray) to handle multiple tray applets in one process ... btw I could probably make something similar to sit for gtk1, but it would need to be swallowed by the tray... didn't you already do one using only xlib and xpm though?_________________Web Programming - Pet Packaging 100 & 101