[Jprogramming] Example bash shell scripts using J 7.01
David Ward Lambert
b49P23TIvg at stny.rr.com
Fri Sep 30 04:52:27 HKT 2011
Response to John Baker's request for unix shell script
Message-ID:
<CABc=tNyZuqgGK4tL0aRAXRkb7=OzdDFO9PYFoL2p+ZuAAu4a5w at mail.gmail.com>
and a follow on to bill lam's message
Message-ID: <20110929150714.GA2845 at debian.b2j>
I do not know what Bill's jb program is and have been unable to
execute j scripts that start with #! /path/jconsole
Instead I use a bigger hammer: exec
The j script can appear in the shell script as shown.
Warning, I modified his j code without testing. (A further optimization
would be to read only the last character of the file.)
Quoting 'EOF' prohibits parameter expansion in the here document. j
programs often contain $ . Copy the following to file (say s.sh),
follow it's instructions.
#!/bin/bash
# $ chmod +rx s.sh # change mode to executable
# $ ./s.sh *suspects* # append new lines if necessary to suspect files
F=/tmp/j.ijs
cat<<'EOF'>$F # copy here document to EOF to file of expanded $F
3 : 0'' NB. If necessary, append LF to files listed on command line
for_f. }.ARGV_j_ do.
if. LF~:{:1!:1 f do.
stdout LF,>f
LF 1!:3 f
end.
end.
)
exit 0
EOF
J=/usr/local/j64-701/bin/jconsole
exec $J $F $*
More information about the Programming
mailing list