#!/bin/bash #set -x mkdir -p temp tempFile=temp/accountNumbers.tmp.$$.json tempFlatFile=temp/accountNumbers.flat.$$.tsv curl -s -X GET "https://api.schwabapi.com/trader/v1/accounts/accountNumbers" -H "Authorization: Bearer $( ${tempFile} (jq -r '.[] | [.accountNumber, .hashValue ] | @tsv' < ${tempFile} | while read accNo accHash; do read accInfo <<< $(grep ${accNo} accountNumberNameMapping.dat; echo ${accNo}) echo ${accInfo} ${accHash} done) >> ${tempFlatFile} if [[ "$1" != "" ]]; then read accName accNum accHash <<< $(grep $1 ${tempFlatFile}); echo -n ${accHash} else cat ${tempFlatFile} fi