Operating System - HP-UX
1835549 Members
2838 Online
110078 Solutions
New Discussion

embed backslash in shell script

 
SOLVED
Go to solution
Timothy Nibbe
Advisor

embed backslash in shell script

I am trying create a shell script that appends users to smbusers.

The added line should look like:

8_charid = domain\long_userid

I would think that this line should work:

echo $1" = domain\\"$2 >> /etc/samba/smbusers

It doesn't always work. The most interesting case is if $2 starts with an 'n', it is interpreted as a carriage return.

Example:

# test,sh mmmm nnnn

# cat smbusers
mmmm = domain
nnn

-------------------------------------

I would have expected it to be:

# test,sh mmmm nnnn

# cat smbusers
mmmm = domain\nnnn
2 REPLIES 2
Tingli
Esteemed Contributor
Solution

Re: embed backslash in shell script

You can use ' instead of ".
Timothy Nibbe
Advisor

Re: embed backslash in shell script

Thanks, the ' instead of " worked.