Skip to main content

Questions tagged [quoting]

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

2 votes
1 answer
224 views

How to proberly deal with quotes in filenames when using variables/arrays including the filenames in bash? [duplicate]

I have been working on a bash script for a few days and got stuck with filenames including single and double quotes. Give I want to iterate over the following files in a directory: 'file1.txt' 'file2....
benjamin10's user avatar
0 votes
0 answers
28 views

In the nullmailer `remotes` configuration file, how do I quote single quotes in the password?

I'd like to use nullmailer to have my Debian (bullseye and bookworm) systems send system-generated email messages to the appropriate recipient. nullmailer is configured (among others) by the file /etc/...
Binarus's user avatar
  • 3,410
0 votes
1 answer
82 views

Linux program to quote filename only when necessary?

Consider having these directories and files: $ tree /tmp/test /tmp/test ├── dir │   ├── file_normal │   ├── file with "double quote │   ├── file with 'single quote │   ├── file with space │   └── ...
midnite's user avatar
  • 443
0 votes
1 answer
47 views

What is the difference between quotes wrap around only the option value vs quotes wrap around the option name and option value?

What is the difference between quotes wrap around only the option value eg: grep --file="grep pattern file.txt" * vs quotes wrap around the option name and option value eg: grep "--...
Nor.Z's user avatar
  • 133
0 votes
1 answer
60 views

How can I edit matching files if the paths contain whitespace in bash?

I sometimes grep (or rg aka ripgrep or ag aka silversearcher) for things and then want to edit the matching files. For the editor part I use bash's history. ~$ rg someThing ./path/to/some/file.txt 1:...
Robert's user avatar
  • 156
0 votes
1 answer
129 views

how to write function with nested commands [duplicate]

I'm trying to write a find and cd function like so: findcd () { cd "$(dirname "$(find '$1' -type '$2' -name '$3')")" } to be called like so: find . f [FILE_NAME] But it's ...
Mathew's user avatar
  • 243
1 vote
1 answer
178 views

Run `git commit -m` with single quotes in zsh

I sometimes use characters such as ! and $ in commit messages, they need to be manually escaped, but not if you use single quotes like this git commit -m 'My $message here!'. I tried to write a ...
Justin Breen's user avatar
5 votes
2 answers
601 views

Bash reads quotes inside a variable as text, not quotes? Is "Implicit quoting" a thing in Bash?

I've got a bash script that cleans up the mail queue periodically. For Reasons, we've elected to delete any email to @mms.att.net and other email2SMS gateways that are over 9 hours in the queue and ...
Criggie's user avatar
  • 1,791
0 votes
1 answer
231 views

Unable to resolve parameter inside json

I'm using a curl command inside a script (edm.ksh) to retrieve some data from an API, it requires a password in a JSON like {"password":"myPassword"}. Now, myPassword is not ...
Pratik Khobragade's user avatar
7 votes
2 answers
1k views

Echoing "!" inside a string does some weird things [duplicate]

If I type in this: echo "Hello, World!" I don't know the name of it, but it prompts me for the next line. You know the PS2 thing. Or if you type echo \ and press Enter. Why? Well I know ...
Bog's user avatar
  • 1,034
0 votes
1 answer
68 views

Using a variable in between ' 's

I have a bash script with a line that was originally this convert '%d.jpg[1-300]' combined.pdf Uses convert from Imagemagick to strap a load of sequentially numbered jpgs in to a PDF. I've written a ...
Big_James's user avatar
0 votes
2 answers
190 views

Why is echo "\*" the same as echo "\\*"

Title. echo "\*" has the exact same output as echo "\\*", \*. I am using GNU bash 5.2.15. I expected echo "\\*" to output \*, but I do not know why echo "\*" ...
Christopher Lee's user avatar
0 votes
2 answers
494 views

Choose columns with sort and cut in a csv with a comma delimiter ',' ignoring data on quotes with comma "text,text"

I am parsing a huge csv file with rows and columns with different parameters. However, some fields contain large descriptions within quotes that contain commas. How can I choose columns with sort and ...
infinity's user avatar
1 vote
3 answers
377 views

Removing directories with spaces in their directory paths

I'm on macOS. I have many directories at paths that looks like this: ./FirstName SecondName/A Multi Word Title/Contents/Index/files I want to remove ALL the Index directories and their contents. I ...
rbpeirce's user avatar
0 votes
2 answers
205 views

Show quotes with echo inside bash -c

I am trying to echo I say "Hello, World!" with bash -c. This is (some of) what I have tried: $ bash -c "echo I say \"Hello, World"'!'"\"" $ bash -c "echo I ...
Liviu's user avatar
  • 105

15 30 50 per page
1
2
3 4 5
72