Questions tagged [quoting]
Strings are typically delimited by quotes, which raises the problem of dealing with strings that include quotes.
1,075
questions
0
votes
2
answers
984
views
CSV fields max length error and setting quoting=csv.QUOTE_NONE
After running csvcut on a comma-delimited .csv file:
[root@server files]# csvcut -c title,mpn,overview,techspecs2,image_carousel_elargesrc syn_multi-image.csv > syn_scraped_cut.csv
I get the error:...
197
votes
6
answers
300k
views
How can we run a command stored in a variable?
$ ls -l /tmp/test/my\ dir/
total 0
I was wondering why the following ways to run the above command fail or succeed?
$ abc='ls -l "/tmp/test/my dir"'
$ $abc
ls: cannot access '"/tmp/test/my': No ...
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/...
0
votes
1
answer
85
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
│ └── ...
0
votes
1
answer
48
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 "--...
23
votes
6
answers
28k
views
How to assign space-containing values to variables in bash using eval
I want to dynamically assign values to variables using eval.
The following dummy example works:
var_name="fruit"
var_value="orange"
eval $(echo $var_name=$var_value)
echo $fruit
orange
However, when ...
181
votes
1
answer
78k
views
When is double-quoting necessary?
The old advice used to be to double-quote any expression involving a $VARIABLE, at least if one wanted it to be interpreted by the shell as one single item, otherwise, any spaces in the content of $...
18
votes
2
answers
106k
views
How to use a special character as a normal one in Unix shells?
Many questions like 'How to type the double-quote char (")?' are being asked, and we don't want to clutter our community with the same answer (Type it as \" if not enclosed in 's, " if enclosed in 's.)...
1
vote
2
answers
672
views
Problem sending SMS text with a single quote character - mmcli (ModemManager)
This is an example from the mmcli manpage:
mmcli -m 0 --messaging-create-sms="text='Hello world',number='+1234567890'"
The details how it is parsed are unclear, the description says only --messaging-...
0
votes
1
answer
61
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:...
7
votes
4
answers
4k
views
Multiline variable with spaces, adding each line to an array
I have a problem I can't seem to figure out..
I'm making a script I will run in OSX to help me stay connected to open wifi hotspots.
I am reading all surrounding wifi networks into a muntiline ...
0
votes
1
answer
133
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 ...
1
vote
1
answer
181
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 ...
155
votes
5
answers
471k
views
How to escape quotes in the bash shell?
I'm having trouble with escaping characters in bash. I'd like to escape single and double quotes while running a command under a different user. For the purposes of this question let's say I want to ...
20
votes
2
answers
12k
views
How Can I Expand A Tilde ~ As Part Of A Variable?
When I open up a bash prompt and type:
$ set -o xtrace
$ x='~/someDirectory'
+ x='~/someDirectory'
$ echo $x
+ echo '~/someDirectory'
~/someDirectory
I was hoping that the 5th line above would have ...