From a31ea7cfd15549d4e0a62c512c89d33463a9185b Mon Sep 17 00:00:00 2001 From: "vg@devys.org" Date: Mon, 27 Aug 2018 17:31:25 +0200 Subject: Fix swapped arguments due to comm command --- bulkrename | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bulkrename b/bulkrename index a488381..5fb2134 100755 --- a/bulkrename +++ b/bulkrename @@ -15,7 +15,8 @@ namebase="$(mktemp -d)/blkrn" echo '# Modify filenames without removing any line, quitting aborts' \ > "${namebase}.2" tee -- "${namebase}.1" >> "${namebase}.2" -exec /dev/tty || { echo 'Interactive terminal needed' >&2 ; exit 1; } +exec /dev/tty \ + || { echo 'Interactive terminal needed' >&2 ; exit 1; } "$EDITOR" "${namebase}.2" sed -i -- '1d' "${namebase}.2" @@ -25,12 +26,11 @@ if [ $(wc -l < "${namebase}.1") -ne $(wc -l < "${namebase}.2") ] ; then echo "Wrong number of lines" >&2 ; exit 1 fi -sed -i -- 's/\([\\"$`]\)/\\\1/g;' "${namebase}.1" "${namebase}.2" - (echo '# Please review/modify this script or empty it to do nothing' \ - ; comm -3 --output-delimiter="" "${namebase}.1" "${namebase}.2" \ - | tr -d '\0' \ - | sed 's/^.*$/"&"/' \ + ; while read -r l1 <&3 && read -r l2 <&4; do + [ "$l1" = "$l2" ] || printf "%s\n%s\n" "$l1" "$l2" + done 3<"${namebase}.1" 4<"${namebase}.2" \ + | sed 's/\([\\"$`]\)/\\\1/g;s/^.*$/"&"/' \ | xargs -d"\n" -L2 echo 'mv -i --') \ > "${namebase}.sh" -- cgit v1.2.3