Segmentation fault in awk pipeline
a-shell up-to-date,App Store claims version is 1.15.3
$ file Untitled.jpg | grep -o '\(precision.*$\)'| awk -F , '{ print $2 }'| awk -F x '{ print $1 }'
15402
segmentation fault
$
Leaving off the last awk does not have a segmentation fault.
$ file Untitled.jpg | grep -o '\(precision.*$\)'| awk -F , '{ print $2 }'
15402x5360
$ file Untitled.jpg | grep -o '\(precision.*$\)'
precision 8, 15402x5360, components 3
$ file Untitled.jpg
Untitled.jpg: JPEG image data, JFIF standard 1.01, resolution (DPI), density 72x72, segment length 16, Exif Standard: [TIFF image data, big-endian, direntries=11, manufacturer=Canon, model=Canon EOS R7, orientation=upper-left, xresolution=166, yresolution=174, resolutionunit=2, datetime=2025:03:13 22:33:23], baseline, precision 8, 15402x5360, components 3
Yes, it's tricky to run the same command simultaneously, since a-Shell does not have separate memory for each command. What happens is that the first awk has freed the memory, and the second awk is either trying to access the memory that was just freed or to free it again.
There's no short term solution (the awk code base is too complex for the simple tricks I used for grep, for example).
One possible workaround would be to install gawk with pkg install gawk, then pipe awk into gawk, for example. These are two different commands. Another workaround would be to install the cut comment (with pkg install cut), then use it instead of awk:
file test.jpg | grep -o '\(precision.*$\)'| cut -d ',' -f 2 | cut -d 'x' -f 1
I'm not certain it'll work, but you could also try piping gawk into gawk. It'll probably work, but it will also be slower than the version with cut.
$ file Untitled.jpg | grep -o '\(precision.*$\)'| awk -F , '{ print $2 }'| cut -d 'x' -f 1
15402
Works great. Thank you.