The awk script is using heuristic to determine where to insert the Duplex commands in the file.
The bash script is using the bash "feature" of sending to a network socket using the fake device paths that are builtin to bash.
#!/usr/bin/awk -f | |
{ print } | |
/%EndFeature/ { | |
print "%%BeginFeature: *Tumble False" | |
print " (<<) cvx exec /Tumble (false) cvx exec (>>) cvx exec setpagedevice" | |
print "%%EndFeature" | |
print "%%BeginFeature: *Duplex True" | |
print " (<<) cvx exec /Duplex (true) cvx exec (>>) cvx exec setpagedevice" | |
print "%%EndFeature" | |
} |
#!/bin/bash | |
# duplex command is the awk script in your PATH | |
PRINTERADDRESS=169.254.1.1 | |
duplex < "$1" > /dev/tcp/${PRINTERADDRESS}/9100 |