简体   繁体   中英

escaping colon in bash script

Good day all, I am trying to write a script in which a command should contain the colon character ':'. Looking at this document , characters can be escaped using this character '^', but they do not mention the colon character.

The command should be:

iwconfig wlan0 key s:AsciiPassword

So in my script I have something like:

iwconfig $interface key s:$password

When I run the first command manually, it obviously does what is expected, but the second one in the script, Nothing!!! Would appreciate any help

Update: I cannot really produce an output because the command does not produce any.

That document you link relates to windows.

In bash ; escape with '\\'.

You also likely want to quote your variable expansions

I would imagine you need:

iwconfig "${interface}" key s:"${password}"

You may need to escape the :, though I doubt it. If so it would be:

iwconfig "${interface}" key s\:"${password}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM