Snippets

emptypage Swap pairs of file names

Created by Masaaki Shibata last modified
#!/bin/sh

if [ $# == 0 ]
then
	cat <<- EOS
	swaprename file1 file2 [file3 file4] ...
	
	Swap pairs of file names; file1 and file2, file3 and file4, ...
	EOS
	exit
fi

while [ $# -ge 2 ]
do
	echo "$1 <-> $2" 1>&2
	mv "$1" "$1.tmp"
	mv "$2" "$1"
	mv "$1.tmp" "$2"
	shift 2
done

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.