puzzles/vertical-slashes/verticalslashes.sh

24 lines
603 B
Bash
Raw Normal View History

2024-04-02 21:01:09 +00:00
#!/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