Skip to content

Instantly share code, notes, and snippets.

@kadler
Last active October 20, 2021 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kadler/2907a5e4eb9068118ffe9fb2eeede680 to your computer and use it in GitHub Desktop.
Save kadler/2907a5e4eb9068118ffe9fb2eeede680 to your computer and use it in GitHub Desktop.
Convert SRCPF member to stream file
#!/QOpenSys/pkgs/bin/bash
MBRPATH=/qsys.lib/qsysinc.lib/h.file/stdio.mbr
RCDLEN=80 # default, use whatever was specified on CRTSRCPF
CCSID=037 # needs leading zeros if less than 3 digits
OUTFILE=stdio.h
# What it does:
# 1. Convert the member "stream of bytes" to UTF-8
# 2. Split the byte stream in to RCDLEN sized lines
# 3. Strip any trailing whitespace from each line
/QOpenSys/usr/bin/iconv -f IBM-$CCSID -t UTF-8 "$MBRPATH" |
fold -b -w $RCDLEN |
sed 's| *$||g' > "$OUTFILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment