#!/bin/bash LEDGERS=$(bin/ls-ledgers) MAPPING=".icsv2ledgerrc-mapping" bin/diff-accounts | \ while IFS=$'\t' read old_acct _sep new_acct ; do for l in $LEDGERS ; do bin/rename-account "$old_acct" "$new_acct" "$l" done sed -ri "s/,${old_acct}(,|$)?/,${new_acct}\\1/" "$MAPPING" done