Skip to main content

All Questions

Tagged with
0 votes
1 answer
57 views

value of $VAR already contains backtick and/or single quote inside. How to handle it? How to properly pass $VAR to program? [duplicate]

$ bash --version GNU bash, versione 5.2.26(1)-release (x86_64-pc-linux-gnu) I don't know how to deal with $VAR when its value inside contains single quote (') and/or backtick (`). I'm in the need of ...
dAllARA's user avatar
  • 33
-1 votes
1 answer
42 views

I can't grep some inputrc string

bind -p |grep -E "\\e.\":" work but bind -p |grep -E "\\e\\C-.\":" don't work I tried a lot of combination
user3634569's user avatar
5 votes
1 answer
450 views

ls output display a file named "N'*" as "N'\''*"

System: Ubuntu 22.04.3 LTS GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu) ls (GNU coreutils) 8.32 Situation: $ touch "N'*" $ ls 'N'\''*' "GNU Coreutils - Quoting File ...
yossi-matkal's user avatar
1 vote
1 answer
120 views

bash cd issue with path containing spaces: "too many arguments" [closed]

I created a path with spaces, and when I try to change directory I get "too many arguments" error message despite escaping the spaces or quoting the path : Here are the tests I made : # ...
creatldd1 creatldd1's user avatar
-1 votes
3 answers
94 views

How to use a variable in a command inside of a bash file

I use this command directly on our redhat linux server 8.8 and it's working correctly and I get the result I want: grep '01-FEB-2024' /u01/app/server1/listener_scan/trace/listener_scan.log | awk '{ if ...
TimLer's user avatar
  • 101
0 votes
0 answers
59 views

Why isn't passed quoted $@ a single argument? [duplicate]

Why isn't passed quoted $@ a single argument? f2() { echo "f2: $1" } f1() { local x=("$@") f2 "${x[@]}" } f1 x y Invocation: $ bash t537.sh f2: ...
pmor's user avatar
  • 619
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
1 vote
1 answer
99 views

Why does -n with unquoted variable containing empty string return true? [duplicate]

From man bash: -n string True if the length of string is non‐zero. Examples: # expected $ var=""; [ -n "$var" ]; echo $? 1 # unexpected? $ var=""; [ -n $var ]; echo ...
pmor's user avatar
  • 619
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
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
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

15 30 50 per page
1
2 3 4 5
34