sffmny

sffmny              - to read from stdin
or  sffmny filename         - to read from file filename
or  sffmny -s "nnnn" -c filename
or  sffmny -s "nnnn" -o newfile filename
or  cat rhubarb | cut 1-20 | sffmny -o /world/ruby -

If running manually, remember most shells need metas escaped and/or use the
single quote not dbl :
    sffmny -s '<split>' -x -f EN -o /fip/x/archive/\\EN filename

Note that if -f is specified, a FipHdr of that name is added with the first bit
of text after the split OR the item seqno if there is none.

Simple program to read in a file and split it into several files.
The output file has a 4 digit extention.

Input switches :
    filename    input filename is always last (if needed)
            OR '-' to look for stdin.
    -o : output file path and queue         default: (infilename).9999 in current queue
        (see below)
    -s : splitter string to divide files        default: ^
    -m : optional string denoting a common HEAD part of data. default: none
    -M : optional string denoting a common TAIL part of data. default: none
    -n : return the number of files split       default: 0 on success
        in all cases, an error will produce a negative return code.
        note this is unusual behavior ! as most programs return just '0'
    -c : case insensitive               default: case sens
    -h : input file has a FipHdr on         default: no
    -H : Extra FipHdr information to add on     default: no
    -i : ignore end of FIPHdr and merge with data   default: no
    -I : ignore end of FIPHdr and merge with data   default: no
        BUT make sure there is at least one new valid extra FipHdr
        field (that is NOT XX:) before creating the new file.
    -Z : For files with FipHdrs, add this FipHdr field with the Seqno
        eg : -Z SQ adds a FipHdr field 'SQ:0003' etc
    -C : split only on the 'n' count of the split string    default: every occurance
        ie -C 100 - split on the 100th time the end string is found
    -e : do not strip empty files           default: strip
    -E : minimum size of file           default: 1 byte
    -f : FipHdr field for the first non-space bit of data   default: none
    -x : strip the splitter string          default: leave in both files
    -y : splitter string is the end of the old file default: leave in both files
    -Y : splitter string is start of the new file   default: leave in both files
    -z : force seqno number to start with this  default: 0
    -v : version and exit

For those switches with parameters, the parameter MUST be separated by a space.
Yes even on NT !

Other env varis can be used to define where the system is :
    SFF_HOME    where the home or top queue is.     default: /fip
            eg  setenv  SFF_HOME    /ripexpress/underware
    SFF_LOG     where the log files queue is        default: (SFF_HOME)/log
    SFF_SPOOL   where the data queues are       default: (SFF_HOME)/spool
    SFF_TMP     where the tmp data queues is        default: (SFF_HOME)/x
            THIS MUST BE ON THE SAME UNIX VOLUME as SFF_SPOOL queues.
            ie if spools are on /data99 which is hard disk /dev/sd0, you MUST also
            have the TMP queue on the same disk/partition

NOTE that for all BUT SFF_HOME, if the parameter starts with a '/' then it is a
hard, absolute path; if not then the spool area is under SFF_HOME.
    eg  setenv  SFF_SPOOL   /data7      will look under /data7 for queues
    while   setenv  SFF_SPOOL   data7       will look under /fip/data7

----------------------------------------------------------------------
Examples :

    sfffmt -c"\n" < TFTDDMM.YY | awk -f awk.ftlink | sffmny

The default output is to use the basename of the input file and add \$v.

But note that In a script it is normal that you might have to double the
backslashes.

Also in many scripts and CMD windows, chrs like dollars need also to be escaped
with a backslash EG

sffmny -s "ReloadedNeu" -o /fip/spool/xo/zz.\\\$v MyInputFile

#!/bin/sh

#
# Split PCS files for Blue
#

# sffmny
#   -x do not add the splitter sstring
#   -s splitter string
#   -o output path and name (plus Seqno stuffed on end)
#   $1 input file
# double backslash for a single PLUS another to escape the dollar
#
/fip/bin/sffmny -x -s "<URN=" -o
"/fip/spool/xchg/#CX:pcs2blue#CQ:2w5#SN:pcsraw\\\$u.\\\$v" $1

exit 0

Example using count - where the split is on the 'n'th occurance (800 in this
case) of the splitter string '*END'

/fip/bin/sffmny -s '*END' -o '/a1/hoho/split.800.\$v' -C 800
/aa/siftsplit/2008tabloid

Version Control
;004j   30sep99 added -I and -i and -H and -Z
    ;a/b/c 24jul00 minor mods
    ;d 25jul02 made outname parseable
    ;e/f 02aug02 add -m -M and -n (might have broken -I ??)
    ;g-h 12nov02 empty files are now that plus added -E !
    ;i 26may08  added -f
    ;j 26apr09 added -C, -y, -Y and bugette-missing 1 chr on 64k boundary

(copyright) 2017 and previous years FingerPost Ltd.