I am writing a bash script to mount DFS Windows shares via cifs
. I have the main part working, but I am having trouble for when I need the user to enter the DFS path as a variable and convert the backslashes to forward slashes.
#!/bin/bash
FILE='\\edi3\welshch\test'
FILEPATH="$("$FILE" | sed -e 's/\\/\//gp')"
echo $FILEPATH
I had another script that used a command to find a filepath for AD home directories then piped to sed as per the part | sed -e 's/\\/\//gp
However this script above gives me;
./test.sh: line 10: \\edi3\welshch\test: command not found
FILE='\\\\edi3\\welshch\\test'
– Panki Oct 18 '19 at 10:40FILE='\\\\edi3\\welshch\\test'; echo "$FILE"
– ilkkachu Oct 18 '19 at 10:45\\edi3\welshch\test
for me – Panki Oct 18 '19 at 10:51echo
there was my mistake. Try withprintf "%s\n" "$FILE"
instead. Or something likefoo='\\\\'; echo "${#foo}"
(gives the length of the string). – ilkkachu Oct 18 '19 at 10:54