diff options
-rwxr-xr-x | bulkrename | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -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 >/dev/tty || { echo 'Interactive terminal needed' >&2 ; exit 1; } +exec </dev/tty >/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" |