Skip to main content

All Questions

Tagged with
-2 votes
3 answers
1k views

quoting problem with mysql

I'm running the following command and receiving an error related to quoting or something. #!/bin/bash test='my_table' date='2020-10-31 00:00:00.000000' mysql --user=halloween --password='ghost_123' --...
Ian Arman's user avatar
1 vote
1 answer
353 views

To what does an unquoted empty variable expand in bash?

To what value does an unquoted, undeclared variable expand to in order to return an exit status of 0? Here is an example of a particular situation I ran into: [ -n $var ]; echo $? 0 [ -n "$var&...
twan163's user avatar
  • 5,700
5 votes
3 answers
5k views

Escaping double quotes inside command substitution

I am attempting to write a simple bash parser. I am following the steps in this wiki. One of the assumptions I make is that I can do a pass over the entire input string and remove all single and ...
falky's user avatar
  • 189
1 vote
1 answer
973 views

Command substitution inside double quotes

I am attempting to write a bash parser. Many resources have referred to this wiki One area I am getting stuck is why the following would work echo "$(echo "hi")" # output => ...
falky's user avatar
  • 189
1 vote
2 answers
226 views

How to construct bash command and arguments for ssh / su -c

I'm backing stuff up from an array list of sources, a bit like this simplified version: sources=( file1 file2 "other stuff" ) backupcommand="rsync -ar ${a[@]} dest/" su backupuser -...
artfulrobot's user avatar
  • 2,949
2 votes
3 answers
317 views

How to double quote a wildcard pattern of files?

I've seen a bunch of similar questions to this one but none exactly the same. I have a directory of files which I want to pass in as a single, double-quoted argument to a command, using wildcard ...
Michael Kolber's user avatar
0 votes
1 answer
30 views

how to arrange quotes in this bash command

my_cmd --attr1 $(($1-$2)) --attr2 $(($1-$2+$3)) --attr3 $(($2+1)) I have this command and I would like to debug it (put it in echo and see how command will look like) but I am struggling with ...
quester's user avatar
  • 293
0 votes
1 answer
244 views

dash: How can I quote the arguments ala "${(q+@)@}" in zsh?

I want to quote the arguments in dash (or sh, or even bash if that's not possible). I can do that with "${(q+@)@}" in zsh, such that reval <sth> ... is the same as just typing in <...
HappyFace's user avatar
  • 1,620
-1 votes
1 answer
900 views

bash while loop irritate with single quote

I have a few lines code. I just want to check if argument $1 is in the file with a while loop so I write this code. #!/bin/bash if [ ! -z $1 ] then update=$1; while read line do if ...
Mahdi's user avatar
  • 19
1 vote
2 answers
382 views

How to execute function within double quotes?

I have these function: #execute vim and then exit on err return ve() { vim "$@" || exit } export -f ve #compile c source -> asm source in new tab in xfce terminal casm() { [ -z ${1} ] &&...
Herdsman's user avatar
  • 350
0 votes
2 answers
701 views

How can I define and use `alias` within `bash -c` with a one-line command?

I am trying to define and use alias within bash -c with a one-line command. The command: bash -c "eval $'df'" works fine, but: bash -c "eval $'alias df5=df\ndf5 -h'" doesn't. Why, and how can I ...
Franck Dernoncourt's user avatar
1 vote
2 answers
1k views

How to escape a "\" in command parameters [duplicate]

I have a command path/to/forticlientsslvpn_cli --server <host>:<port> --vpnuser testpass\101 When I run the script, linux puts a space between testpass and 101. I want the script to see ...
Tlou Rammala's user avatar
0 votes
2 answers
232 views

How to expand variable within a single-quoted argument?

I am trying to perform the following without luck: SORT_BY='-k3,3r -k2,2 -k1,1r' awk 'NR<4{print $0;next}{print $0 | sort '"${SORT_BY}"' -t"~"}' I have tried with all sorts of quotes, unquote, ...
Whimusical's user avatar
1 vote
1 answer
521 views

sed bash script is unexpectedly replacing character with space instead of newline [duplicate]

Using bash command syntax: echo "The*quick*brown*fox"|sed s/*/\\n/g I get the desired output: The quick brown fox However in script: IN_TXT="The*quick*brown*fox" OUT_TXT=$(echo $IN_TXT|sed s/*/\\...
SPB's user avatar
  • 13
0 votes
2 answers
4k views

using awk to print backslash

I am having trouble printing (or searching) for sequences containing backslashes when using awk For example - echo "test\test" | awk '{ gsub(/\\\\t/, "\\\\&"); print }' will give the result: ...
tomer's user avatar
  • 1

15 30 50 per page
1 2 3
4
5
34