Created
December 15, 2017 04:59
-
-
Save ernstki/10c139ee05dd189cba8663638af67bc3 to your computer and use it in GitHub Desktop.
reslashify - a sed script to reverse slashes in pathnames (DOS <--> Unix)
This file contains hidden or 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 sed -f | |
# replace all forward slashes only if there are no backslashes | |
# (i.e., convert Unix-style pathnames to DOS/Windows-style ones) | |
/\\/! s_/_\\_g | |
# branch (to the end) if any substitutions have been made at this point, | |
# to prevent the next pattern from undoing what the first one did | |
t | |
# replace all backslashes only if there are no forward slashes | |
# (i.e., convert DOS-style pathnames to Unix-style ones) | |
/\//! s_\\_/_g | |
# vim: ft=sed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment