X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/849106f7246e47bc077d7f3b8228cec717a8e63d..26f0533782d8c57fb95b8df4f55057edcbf17703:/unitproc/bktemp-writeArg diff --git a/unitproc/bktemp-writeArg b/unitproc/bktemp-writeArg deleted file mode 100644 index d3c1f02..0000000 --- a/unitproc/bktemp-writeArg +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -# Desc: Template function to write data supplied as argument - -yell() { echo "$0: $*" >&2; } # Yell, Die, Try Three-Fingered Claw technique; # Ref/Attrib: https://stackoverflow.com/a/25515370 -die() { yell "$*"; exit 111; } -try() { "$@" || die "cannot $*"; } -writeArg(){ - # Desc: Writes first argument with subsequent arguments as options - # Usage: writeArg "$(echo "Data to be written.")" [output path] ([cmd1] [cmd2] [cmd3] [cmd4]...) - # Input: arg1: data to be written - # arg2: output path - # arg3+: command strings (ex: "gpsbabel -i nmea -f - -o kml -F - ") - # Output: file written to disk - # Example: decrypt multiple large files in parallel - # writeArg "$(cat /tmp/largefile1.gpg)" /tmp/largefile1 "gpg --decrypt" & - # writeArg "$(cat /tmp/largefile2.gpg)" /tmp/largefile2 "gpg --decrypt" & - # writeArg "$(cat /tmp/largefile3.gpg)" /tmp/largefile3 "gpg --decrypt" & - # Depends: bash 5 - - # Set command strings - if ! [ -z "$3" ]; then CMD1="$3"; else CMD1="tee /dev/null "; fi # command string 1 - if ! [ -z "$4" ]; then CMD2="$4"; else CMD2="tee /dev/null "; fi # command string 2 - if ! [ -z "$5" ]; then CMD3="$5"; else CMD3="tee /dev/null "; fi # command string 3 - if ! [ -z "$6" ]; then CMD4="$6"; else CMD4="tee /dev/null "; fi # command string 4 - - # Debug - yell "CMD1:$CMD1" - yell "CMD2:$CMD2" - yell "CMD3:$CMD3" - yell "CMD4:$CMD4" - # Write - echo "$1" | $CMD1 | $CMD2 | $CMD3 | $CMD4 > "$2"; - -} # Write Bash var to file - -#==BEGIN sample code== -myFile="/tmp/$(date +%s)..original" -echo "how are you doing?" > "$myFile" -myVAR="$(cat $myFile)" -writeArg "$myVAR" "$myFile..LOUD_CHILD" "tee /tmp/cloneityclone " "tr '[:lower:]' '[:upper:]'" -#==END sample code== - -# Author: Steven Baltakatei Sandoval -# License: GPLv3+