Created
February 6, 2014 16:15
-
-
Save knksmith57/8847335 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
temp = 'some-temp-file-that-doesnt-exist' | |
args = ARGV.shuffle! | |
last = args.last | |
cur = args.shift | |
unless !cur.nil? | |
# need to provide some args! | |
exit! | |
end | |
# start with renaming the first file to temp | |
File.rename cur, temp | |
# recurse through all args | |
args.each do |a| | |
File.rename a, cur | |
cur = a | |
end | |
# finally, rename the last file back to the one we stored in temp | |
File.rename temp, cur |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment