Skip to main content

All Questions

Tagged with
0 votes
0 answers
45 views

escape in double and single quotation [duplicate]

I am confusing why bash can escape "..." but can't escape '...'? Can some one give me a hint? Thanks test@test:~$ echo "He said, \"Hello world\"" He said, "Hello ...
joe's user avatar
  • 53
2 votes
1 answer
2k views

pass long html string as argument to bash script (Filename too long)

I am passing an html string as an input to a bash script: Script.py def bash(commandStr): subprocess.Popen(commandStr, shell=True, executable="/bin/bash") def sendmail(subject, to, ...
Leftover Salad's user avatar
0 votes
2 answers
236 views

How do I convert this script into an alias (MacOS, ZSH) [duplicate]

This script works fine when directly typed into the console: N | find . -type f -iname "*.aac" -exec bash -c 'FILE="$1"; ffmpeg -i "${FILE}" -acodec libmp3lame "${...
Vadorequest's user avatar
1 vote
2 answers
4k views

Bash: How do I quote shell arguments with spaces inside a variable containing multiple arguments without using an array? [duplicate]

In Bash, is it possible to pass a variable with a properly-quoted list of options to a command and not have it split on whitespace inside quotes? IOW, this script: MYCONFIG="--hi FOO=bar 'X=ABC ...
theory's user avatar
  • 127
3 votes
2 answers
280 views

Why does the command echo `echo \\\\\\\z` in bash script print \\z instead of \\\z?

The command echo `echo \\\\\\\z` is from this book , I don’t understand why it prints \\z when it get executed via the bash script. I think it should print \\\z
ll cool's user avatar
  • 31
0 votes
2 answers
476 views

Pass qouted filename with spaces in a bash variable [duplicate]

In a bash shell, consider this: $ x="-name 'foo bar'" $ find $x find: paths must precede expression: `bar'' $ find -name 'foo bar' ./foo bar What can I put in $x to make find $x behave like ...
oskark's user avatar
  • 21
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
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
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
0 votes
1 answer
309 views

Quoting a command line argument containing a variable that may have both single and double quotes in its expansion

After some unsuccesful attempts at quoting the command string correctly, I ended up using the below command to run the identify command on the .jpg files under the working directory, the names of ...
detic's user avatar
  • 33
0 votes
2 answers
484 views

Quoting directory names in bash prompt

I want to quote the current directory in my prompt. Eg, if I do: mkdir $'new\nline'; cd $'new\nline' I want my prompt to display $'new\nline', and NOT print a literal newline. I'm seeing ...
Tom Hale's user avatar
  • 31.2k
0 votes
1 answer
541 views

Why cat command redirect a new file get executed right away?

I want to generate a bash file that could be called later, like this cat <<-SCRIPT >test-$$ #!/bin/bash osType=$(grep -Po '^NAME="\K[^"]*' /etc/os-release) if [ "$...
Tiger's user avatar
  • 347
0 votes
1 answer
113 views

Make shell interpret operators enclosed in single-quotes [closed]

I have two commands built using the logical operator &&. The two commands are enclosed in single-quotes because they are to be passed as a command to root: $ su -c 'sed -i '1i TEXT' file1.txt ...
bit's user avatar
  • 1,116
6 votes
4 answers
6k views

How to prevent command substitution on the command line?

I find that when writing text as input to another program, any command substitutions in double quotes within the intended text are interpreted and expanded by the shell The links in the answer here ...
bit's user avatar
  • 1,116

15 30 50 per page
1
2 3 4 5
14