quoting

How I do invoke a PowerShell Start-Process command with arguments that require quoting from a Command Prompt / batch file?

若如初见. 提交于 2019-12-24 08:20:07
问题 I am getting this error when trying exec one command in PowerShell : I am trying to exec this command: powershell.exe Start-Process -FilePath "C:\Windows\System32\attrib +h +s "%CD%"" -Verb runAs Can someone please help me figuring out why this is happening and how to solve it? 回答1: Can someone please help me figure out why this is happening? The -FilePath parameter of the Start-Process cmdlet expects the name or path of an executable file by itself, not an entire command line . The arguments

bash script - unable to set variable with double quotes in value

China☆狼群 提交于 2019-12-23 20:42:37
问题 Need help in fixing this bash script to set a variable with a value including double quotes. Somehow I am defining this incorrectly as my values foo and bar are not enclosed in double quotes as needed. My script thus far: #!/usr/local/bin/bash set -e set -x host='127.0.0.1' db='mydev' _account="foo" _profile="bar" _version=$1 _mongo=$(which mongo); exp="db.profile_versions_20170420.find({account:${_account}, profile:${_profile}, version:${_version}}).pretty();"; ${_mongo} ${host}/${db} --eval

See exact content of bash variable? (hexdump doesn't help)

别来无恙 提交于 2019-12-22 09:11:14
问题 So I have a problem below, but my question is more generic - how to see exact content of memory referenced by bash variable to understand why they don't match: # [[ $c1 == $c ]] || echo nope nope # [[ $c1 == "bkup dt" ]] || echo nope # [[ $c == "bkup dt" ]] || echo nope nope # hexdump -C <<<$c 00000000 62 6b 75 70 20 64 74 0a |bkup dt.| 00000008 # hexdump -C <<<$c1 00000000 62 6b 75 70 20 64 74 0a |bkup dt.| 00000008 # [ "$c1" = "$c" ] || echo nope nope # [ ! "$c1" = "$c" ] || echo nope Or

How do I escape single quote in command line query of psql?

本小妞迷上赌 提交于 2019-12-22 05:08:29
问题 I googled a lot but.. How do I escape single quote in command line query of psql ? psql -t -A -F $'\t' postgresql://zzzz:5432/casedb -U qqqq -c 'select id,ext_ids ->> 'qwe' as qwe from data ORDER BY qwe' > /jdata/qwe.tab Results in error ERROR: column "qwe" does not exist LINE 1: select id,ext_ids ->> qwe as qwe from data... 回答1: In Postgres you can use dollar-quoted strings: select id,ext_ids ->> $$qwe$$ as qwe from data ORDER BY qwe; -- or select id,ext_ids ->> $anything$qwe$anything$ as

Tool to automatically rewrite a bash script with proper quoting?

北城余情 提交于 2019-12-20 09:47:38
问题 I'm contemplating to make all bash scripts of a large codebase shellcheck compliant, but the task is overwhelming, because too many developers have historically ignored rule number one of all shell scripting: always use quotes. It would be helpful if there was a tool that could fix at least the quoting. I would then be able to fix the rest by hand. My regex didn't cut it, because only variables not already in a string must be quoted. Sample input: echo "Removing $a ${b} $(c $(c)) `d $d` ${10}

Pandas Read_CSV quotes issue

北城余情 提交于 2019-12-19 07:51:12
问题 I have a file that looks like: 'colA'|'colB' 'word"A'|'A' 'word'B'|'B' I want to use pd.read_csv('input.csv',sep='|', quotechar="'" ) but I get the following output: colA colB word"A A wordB' B The last row is not correct, it should be word'B B . How do I get around this? I have tried various iterations but none of them word that reads both rows correctly. I need some csv reading expertise! 回答1: I think you need str.strip with apply: import pandas as pd import io temp=u"""'colA'|'colB' 'word

Do I need to quote command substitutions?

陌路散爱 提交于 2019-12-19 03:23:13
问题 According to the Google Shell Style Guide, I should: Always quote strings containing variables, command substitutions, spaces or shell meta characters, unless careful unquoted expansion is required. Maybe I am misinterpreting what they mean by "command substitutions", but I am wondering if there is any need to use quotes in the following example: VAR="$(echo foo bar)" 回答1: $(echo foo bar) is indeed a command substitution. In this specific example, you don't need double quotes because a

Quoting vs not quoting the variable on the RHS of a variable assignment

懵懂的女人 提交于 2019-12-18 14:52:54
问题 In shell scripting, what is the difference between these two when assigning one variable to another: a=$b and a="$b" and when should I use one over the other? 回答1: I think there is no big difference here. Yes, it is advisable to enclose a variable in double quotes when that variable is being referenced. However, $x does not seem to be referenced here in your question. y=$x does not by itself affect how whitespaces will be handled. It is only when $y is actually used that quoting matters. For

Escape backquote in a double-quoted string in shell

╄→гoц情女王★ 提交于 2019-12-18 13:53:27
问题 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 ` 回答1: 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

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

随声附和 提交于 2019-12-17 20:30:38
问题 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 ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~