quoting

Get and use a password with special characters in Bash shell

蓝咒 提交于 2019-12-02 05:19:48
I'm getting some troubles to use a password with special characters such as $ in a bash shell script. My shell script is : read -s -p "Password : " bindDNPass ldapadd -H ldap://localhost -x -w $bindDNPass -D "dn=cn=Admin" -f /tmp/file.ldif And the password could be something like $Something18$. Well, the command ldapadd -H ldap://localhost -x -W -D "dn=cn=Admin" -f /tmp/file.ldif` asks for my $Something18$ , and works fine. But if I try ldapadd -H ldap://localhost -x -w $Something18$ -D "dn=cn=Admin" -f /tmp/file.ldif it doesn't work. I guess it's trying to resolve the variable $Something18,

Double quotes inside quotes in bash

南笙酒味 提交于 2019-12-02 04:07:29
I need pass $var_path to bash script inside single quotes and then get commnd executed on remote host. I know that single quotes do not allow passing variables, so tried double quoting, but getting error in sed. Assume this happens because its template uses " as well. var="Test text" var_path="/etc/file.txt" echo "$var"|ssh root@$host 'cat - > /tmp/test.tmp && sed -n "/]/{:a;n;/}/b;p;ba}" $var_path > /tmp/new.conf.tmp' so with "" var="Test text" var_path="/etc/file.txt" echo "$var"|ssh root@$host "cat - > /tmp/test.tmp && sed -n "/]/{:a;n;/}/b;p;ba}" $var_path > /tmp/new.conf.tmp" Errors from

How to store a path with white spaces into a variable in bash

给你一囗甜甜゛ 提交于 2019-12-02 03:11:32
问题 I want to store /c/users/me/dir name into a variable to pass it to cd system call. Works when typing: $ cd '/c/users/me/dir name' or $ cd /c/users/me/dir\ name but does not works if I store it: $ dirname="'/c/users/me/dir name'" $ cd $dirname $ bash: cd: /c/users/me/dir: No such file or directory the same result to: $ dirname=('/c/users/me/dir name') or $ dirname=(/c/users/me/dir\ name) Which is the right way to store it? 回答1: Double-quote your path variable with spaces, to preserve it,

R dplyr operate on a column known only by its string name

烈酒焚心 提交于 2019-12-01 12:33:53
I am wrestling with programming using dplyr in R to operate on columns of a data frame that are only known by their string names. I know there was recently an update to dplyr to support quosures and the like and I've reviewed what I think are the relevant components of the new "Programming with dplyr" article here: http://dplyr.tidyverse.org/articles/programming.html . However, I'm still not able to do what I want. My situation is that I know a column name of a data frame only by its string name. Thus, I can't use non-standard evaluation in a call to dplyr within a function or even a script

Handling quoting and escaped spaces in Bash command arguments

☆樱花仙子☆ 提交于 2019-12-01 12:32:22
I am writing a bash script that uses other inputs to build a set of complicated arguments for a command. So far, the script runs perfectly with this technique: whatIwant="command \"$filename-with-spaces-maybe\" -opt1 \"$some_words\" -opt2 $a_number -opt3 \"$a_file_reference\" -opt4 \"$several_sentences\" " eval $whatIwant Although it works, I am wary of using eval because of the risk of a bad filename doing damage. I would like to be able to skip assigning the variable and then eval'ing it, in favor of just putting the command at the beginning of the line and having all the arguments be set by

'kubectl patch' works on Linux Bash but not in Windows Powershell ISE

吃可爱长大的小学妹 提交于 2019-12-01 11:32:49
The following command works fine on Ubuntu bash: kubectl patch deployment wapi-backend-d1 --patch '{"spec": {"template": {"metadata": {"labels": {"date": "test"}}}}}' The same command does not work in Windows Powershell Console (ISE). The error is: kubectl : Error from server (BadRequest): invalid character 's' looking for beginning of object key string At line:1 char:1 + kubectl patch deployment wapi-backend-d1 --patch '{"spec": {"template ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (Error from serv...ject key string:String) [],

R dplyr operate on a column known only by its string name

∥☆過路亽.° 提交于 2019-12-01 11:18:45
问题 I am wrestling with programming using dplyr in R to operate on columns of a data frame that are only known by their string names. I know there was recently an update to dplyr to support quosures and the like and I've reviewed what I think are the relevant components of the new "Programming with dplyr" article here: http://dplyr.tidyverse.org/articles/programming.html. However, I'm still not able to do what I want. My situation is that I know a column name of a data frame only by its string

Handling quoting and escaped spaces in Bash command arguments

六眼飞鱼酱① 提交于 2019-12-01 10:11:23
问题 I am writing a bash script that uses other inputs to build a set of complicated arguments for a command. So far, the script runs perfectly with this technique: whatIwant="command \"$filename-with-spaces-maybe\" -opt1 \"$some_words\" -opt2 $a_number -opt3 \"$a_file_reference\" -opt4 \"$several_sentences\" " eval $whatIwant Although it works, I am wary of using eval because of the risk of a bad filename doing damage. I would like to be able to skip assigning the variable and then eval'ing it,

Do escaped double quotes in command substitution become literals in Bash?

徘徊边缘 提交于 2019-12-01 09:47:20
问题 If I execute this in Bash echo "1 2" I get 1 2 . But if I execute echo \"1 2\" I get "1 2" . Now I would figure if I execute echo $(echo \"1 2\") I would get 1 2 . But again, I get "1 2" . In fact, no matter how many command substitutions in the chain echo $(echo $( ... echo \"1 2\") ... ) I always get "1 2" . Why is that? 回答1: After substituting the output of $(command) back into the command line, the only additional parsing that's done is word-splitting and wildcard expansion. Quotes are

Escape backquote in a double-quoted string in shell

不羁岁月 提交于 2019-11-30 16:52:47
For the command: /usr/bin/sh -c "ls 1`" (a backquote after 1). How to make it run successfully? Adding a backslash before "`" does not work. ` is a special char as we know, and I tried surrounding it with single quote too (/usr/bin/sh -c "ls 1'`'"), but that doesn't work either. The error always are: % /usr/bin/sh -c "ls 1\`" Unmatched ` You need to escape the backtick, but also escape the backslash: $ touch 1\` $ /bin/sh -c "ls 1\\\`" 1` The reason you have to escape it "twice" is because you're entering this command in an environment (such as a shell script) that interprets the double-quoted