On Sun, Sep 18, 2016 at 4:48 PM, Greg Reagle <greg.rea...@umbc.edu> wrote: > On Sun, Sep 18, 2016, at 09:34 AM, Christian Neukirchen wrote: >> 1 loc! >> >> awk 'NR%22==0 { getline _ <"/dev/tty" } {print}' > > Great! And stali has awk. It works pretty well, but doesn't take into > account long lines. >
#!/bin/sh IFS=' ' read l c << EOF $(stty size) EOF cat "$@" | fmt "-$c" -s | awk -v "l=$((l-1))" '!(NR%l){getline _<"/dev/tty"}1' Or using rc: #!/bin/rc ifs=' ' #space and newline size=(`{stty size}) cat $* | fmt -$size(2) -s | awk -v l'='$size(1) '!(NR%(l-1)){getline _<"/dev/tty"}1' -emg P.S. No this is not the best solution, I'm just having fun.