aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvg@devys.org <vg@devys.org>2018-08-27 17:31:25 +0200
committerCédric Picard <cpicard@purrfect.fr>2018-09-01 21:47:37 +0200
commita31ea7cfd15549d4e0a62c512c89d33463a9185b (patch)
treedd4adb648c770ec632827f0ec0653f40acafb690
parente19fe8b4f41506e334c61f371be40b1f7ea65995 (diff)
downloadbulkrename-master.tar.gz
bulkrename-master.tar.bz2
bulkrename-master.zip
Fix swapped arguments due to comm commandHEADmaster
-rwxr-xr-xbulkrename12
1 files 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 >/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"