Skip to content

Instantly share code, notes, and snippets.

@zoeisnowooze
Created November 27, 2022 17:05
Show Gist options
  • Save zoeisnowooze/9d302565748fe8535a25727892533b22 to your computer and use it in GitHub Desktop.
Save zoeisnowooze/9d302565748fe8535a25727892533b22 to your computer and use it in GitHub Desktop.
#!/bin/bash
slashes=$(sed 's/\([\/\\]\)/\1/g' <<< "$1")
while [ -n "$slashes" ]; do
slash=$(cut -c1 <<< "$slashes")
case "$slash" in
" ")
slashes=$(cut -c2- <<< "$slashes");
if [ "$(cut -c1 <<< "$slashes")" != "/" ]; then
echo -n "$slash"
fi
;;
"/")
slashes=$(cut -c2- <<< "$slashes" | sed 's/ \([\\\/]\)/\1/g')
echo "$slash"
;;
"\\")
slashes=$(cut -c2- <<< "$slashes" | sed 's/\([\\\/]\)/ \1/g')
echo "$slash"
;;
esac
done
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment