Questions tagged [quoting]

Strings are typically delimited by quotes, which raises the problem of dealing with strings that include quotes.

Filter by
Sorted by
Tagged with
0
votes
1answer
24 views

Why "$(findmnt | grep "\""proc"\"" | head -n 1)" is zero-length? (what is incorrect with escaping double quotes with `"\""` here?)

I'm surprised that: $ if [ -n "$(findmnt | grep "\""proc"\"" | head -n 1)" ]; then echo 1; else echo 2; fi 2 I've used "\"" before IIRC after ...
0
votes
2answers
26 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 "${...
1
vote
2answers
236 views

Please explain the behavior of these parameter expansions using IFS?

I'm trying to figure out how to use the ${parameter%word} expansion with $@ and $*. It started by trying to make a script to combine pdfs using ghostscript, but I ran into some weird behavior with ...
-1
votes
2answers
61 views

How to properly parse a quoted arg-list string in a shell script?

Summary How to convert a single string a "b" 'c d' $'e\nf' into separate arguments, respecting quotes and preserving whitespaces and newlines? Question I'm trying to read and process the ...
0
votes
3answers
112 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 ...
0
votes
0answers
25 views

Quoting inside [[ ]] in bash shell [duplicate]

Inside [[ ]] I do not need to quote variables right? Rather than if [[ "$flrm" == *"org"* || "$flrm" == "all" ]]; then printf '%s\n' "Delete: $fl" ...
1
vote
3answers
30 views

How to use argument in single quotes

I have a file, which contains ids: 123abc 456dbc I want to pass them in to a command while I iterate over the the file. Currently, my command works like this: part_of_command '{"id":{"...
0
votes
2answers
94 views

Sed can not replace when string contains double quotes

Output error from the execution of sed command: sed: -e expression #1, char 14: unterminated `s' command command file that I am trying to execute: #!/bin/sh old_version='\"version\": \&...
0
votes
2answers
70 views

Array Declaration: Double Quotes & Parentheses

Perhaps this is a stupid question but two hours on Google hasn't turned up anything on point. Simply, does a difference exist in Bash between: X=" a b c " and X=( a b c ) The former ...
0
votes
1answer
74 views

Escaping "all prerequisites" variables in Makefile

Let's assume we have a couple of files whose names need to be quoted when used in a shell: echo A > 'a.$A' echo B > 'b.$B' And there is a Makefile with a rule that depends on these files: all: ...
0
votes
1answer
48 views

Problem with command for memory stress - Unexpected end of string

I have a problem with this command in Python. stress-ng --vm-bytes $(awk '/MemAvailable/{printf "%d\n", $2 * 0.95;}' < /proc/meminfo)k --vm-keep -m 1 I need double quotation marks at the ...
4
votes
2answers
334 views

Bash's read builtin errors on a string-based timeout option specification but not an array-based one. Why?

In reading through the source to fff to learn more about Bash programming, I saw a timeout option passed to read as an array here: read "${read_flags[@]}" -srn 1 && key "$REPLY&...
2
votes
2answers
144 views

Removing single quotes from double-quoted variable element in array and run a command [duplicate]

I have a script where I dinamically change the arguments which must be passed to a command (mkvpropedit in this case). Consider the example script below: #!/bin/bash LANG_NAME="eng lish" ...
0
votes
1answer
26 views

case-substring function and quoting

i use a simple function in a script in order to ckeck if a string contains a particular substring: #!/bin/bash # subs() { case $2 in *$1*) return 0 ;; *) ...
3
votes
2answers
129 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
2
votes
1answer
55 views

Does + need to be escaped in find commands?

I have the following code in bash and I wonder on whether I can get rid of \+ and simply use + find "$fdir" \ -type f -name "*.org" -o -name ...
2
votes
1answer
280 views

issues with $ symbol while reading from positional parameters in unix shellscript

I have written the following script: #!/bin/bash TEST=$1 TEST_1=$2 if [[ "$TEST" == e ]];then echo $TEST_1 else echo "Input is not e" fi Now if I will run: sh test.sh e NS3#$xX$...
2
votes
2answers
155 views

Unzip a .zip which includes directories with spaces in Name

I have a problem with unzipping my transfered .zip file. Firstly, I zipped a owncloud data directory with the encryption parameter. Then I transfered it to my new Server und would like to unzip it ...
1
vote
2answers
171 views

How to quote exclamation marks in file names in a tcsh shell script with find and awk?

I have a script that searches for space characters ' ', exclamation marks '!' and dollar signs '$' in filenames and replaces each with an underscore '_'. However, it does not handle file names with ...
3
votes
1answer
229 views

Grep pattern that has double quotes and variable substitution surrounded by single quotes

So, Let's say I have the following pattern: Thisisatest="1" in a file called file. And I want to match the exact string above but for whatever reason, I choose to loop over some numbers ...
5
votes
3answers
542 views

How to recursively set directory permissions with a find that lacks -exec?

My Qnap NAS is cursed with a find command that lacks the -exec parameter, so I have to pipe to something. The shell is: GNU bash, version 3.2.57(2)-release-(arm-unknown-linux-gnueabihf) I'm trying to ...
1
vote
1answer
145 views

How to insert ESC control characters in a file in FreeBSD?

I want to enclose Fortran comments with two escape commands (ESC+E and ESC+F). This implies detecting the comment that begins with ! until end of line, and prefixing it with ESC+E and suffixing it ...
5
votes
3answers
696 views

How to match a literal string containing an unclosed quote with ripgrep?

I have a file that contains the some python code. There is a line that contains the following(including the quotes) 'hello "value"' I want to search 'hello "value" in the file. ...
0
votes
1answer
76 views

BASH ANSI-C Quoting - what is the Escape character \E

According to the GNU Bash manual (section 3.1.2.4 ANSI-C Quoting) $'\E' should expand to "an escape character (not ANSI C)". What is this escape character? Is it the character equivalent to ...
0
votes
2answers
33 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 ...
0
votes
0answers
17 views

ASH scripting quotes in backticks works with echo but not with actual execution [duplicate]

I am creating a script for my router (running busybox). In my script I generate a command in a variable like nvram set option='value with spaces' but when it is executed it complains that arguments ...
1
vote
1answer
402 views

Using single quotes inside input of heredocs

I need some help debugging my tcsh script. It uses heredocs. The code: <pre_setup> <<EOF1 <setup> <<EOF2 <command> exit 0 EOF2 exit 0 EOF1 The <pre_setup> is ...
0
votes
1answer
100 views

What exactly these tr commnads do?

I am rewriting some commands that were run using WSL on a Windows machine and need to accomplish the same thing in Python. I am having a really hard time figuring out what exactly these commands are ...
2
votes
1answer
183 views

How to escape all of the special characters in order to be able to print the string as is?

I'm creating a tcsh script on the fly (with a static language). I have a <add-command-here> section that contains some command. I want to do: echo <add-command-here> In that <add-...
1
vote
0answers
86 views

How to move all the files with specific prefix of the directory? [duplicate]

I have a following directory structure (assume no two files have the same name): Apple1 apple1.jpg apple2.jpg Apple2 apple3.jpg apple4.jpg Apple3 Tomato Peach And i would like to move one ...
3
votes
4answers
383 views

Using cut with pling/exclamation mark as a delimiter

In shell (not Bash) I have a string like this that I want to parse: stringhere/morestring!99 After parsing, I want to keep the 99 at the end, and throw away the rest of the string. The substring that ...
3
votes
1answer
65 views

Why does substituting eval with declare (for creating dynamic variables) result in an empty variable?

With bash >5, I'm trying to assign a different value to variables depending on the architecture specified in a variable. I use a function to do so. This works perfectly: # arguments: variable ...
3
votes
1answer
98 views

Cannot understand this bash shell argument expansion

Totally crazy about the following commands: declare -a partition_files readarray -d '' partition_files < <(find "$choosen_image_folder" -name "*sda${i}.gz*") # this does not ...
0
votes
0answers
28 views

How to iterate over matches which contain spaces [duplicate]

I have a file that looks like this # ... stuff @late() def test1(): # ... @late() def test2(): # ... I need to get each match after the @late() line and do some work on them. I've tried ...
5
votes
2answers
416 views

Why does quoting not protect filenames that start with "-" against mis-interpretation? [duplicate]

This might be a ridiculous post, but let's say we have a file called -|h4k3r|-, why doesn't this quoting work? cat '-|h4k3r|-' I thought single quotes remove meaning of all special characters? ...
0
votes
2answers
64 views

Converting multiline to single line in a file looses double quotes

Here is my sample file cat test.txt "IND WEB", "Speed Web (Internal webserver)", "Web Bill", I tried the below two solutions to convert multiline to single line however ...
0
votes
2answers
125 views

Bash interpreting special character within single quotes [duplicate]

Ran into some unexpected but interesting behavior. I was doing a somewhat complex execution when I ran into a situation that from my understanding of how Bash handles characters shouldn't have ...
0
votes
1answer
39 views

Putting single quote in the begining of column

I have a .txt file with publications for which columns are separated by a single space. However, titles also have spaces an in order to separate the columns correctly I need to have all titles in ...
1
vote
1answer
753 views

grep: use square brackets to match specific characters

So I am experimenting with the power of grep using this resources The problem I am currently encountering is that it doesn't seem to work as I intended. so I have an demo.txt file that contains foo....
7
votes
3answers
555 views

How would you gracefully handle this snippet to allow for spaces in directories?

I have a series of commands, e.g.: ssh -i key 10.10.10.10 mkdir -p "${DEST_PATH}/subdir1" "${DEST_PATH}/subdir2" rsync "${SOURCE_PATH}" "$DEST_HOST:${DEST_PATH}/...
0
votes
1answer
43 views

How to set sed command correctly

When I try following commands, (I'd like to rewrite sql). Day='2020/12/1' Dir=/home/test/data sql=`cat $Dir"/"$test".sql" | sed -e "s/Day/$Day/g"` I suffered following ...
2
votes
1answer
533 views

Escaping backlash and double quotes inside a sed expression (surrounded by double quotes)

$ echo 'output: " ' | sed "s/\"/\"/" output: " $ echo 'output: " ' | sed "s/\"/\\\"/" output: " $ echo 'output: " ' | sed "s/\&...
1
vote
1answer
593 views

What is the right way to set header in the youtube-dl config file

I checked the documentation: --add-header FIELD:VALUE Specify a custom HTTP header and its value, separated by a colon ':'. You can use this ...
4
votes
2answers
494 views

ShellCheck warning regarding quoting ("A"B"C")

I am writing simple shell script and when I check my script at https://www.shellcheck.net it give me error at line 14 Line 14: sysrc ifconfig_"${Bridge}"="addm ${NIC}" ...
0
votes
1answer
111 views

Shell causing error in referencing variable in query

I am executing a query in shell to access Google Bigquery table. Cannot figure out what is causing the error. #!/bin/bash file_path='/home/vikrant_singh_rana/test_bq_file.csv' { read while ...
1
vote
1answer
178 views

How to work around wildcard inside double quotes? [duplicate]

In bash, the file globbing * doesn't work inside double quotes, but my filename contains whitespace, so I need to double quote filename before passing it to a shell script. How can I do that? For ...
2
votes
2answers
385 views

Spaces in .desktop file Exec path

I'm trying to create a .desktop file that runs a shell script that's in the same folder as the .desktop file. So far I got the following to work: Exec=bash -xc 'cd "$(dirname %k)" && ...
0
votes
2answers
33 views

Export directory in `bashrc` without having to quote the variable

Currently in my bashrc I export a variable export dl="path/to/Downloads". The path contains a space in it so whenever I mv something from the directory, I have to quote the dl variable such ...
1
vote
1answer
245 views

Unable to run npm install with version specification

I am trying to run a simple npm install with zsh terminal. npm install --save-dev @typescript-eslint/eslint-plugin@^4.0.0 zsh: no matches found: @typescript-eslint/eslint-plugin@^4.0.0 It appears ...
-2
votes
3answers
217 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' --...

1
2 3 4 5
21