I'm trying to write a script that accepts a parameter ($1) with backslashes and I want my script to echo the parameter ($1) exactly with the backslashes entered back.
e.g.
$ ./tst \\abc\def\ghi\jkl\lmn\
\\abc\def\ghi\jkl\lmn\
My tst script at present looks like this;
#!/bin/bash
echo $1
When I run my script it returns;
\abcdefghijkllmn
I want it to return:
\\abc\def\ghi\jkl\lmn\
Exactly what I entered. I've even tried echo -E $1
but that made no difference.
Any suggestions I could achieve my desirable returned output from my script would be very much appreciated.
echo "$1"
; unquoted, the shell will process$1
before passing the result toecho
. – chepner Sep 21 '17 at 12:01