All Questions
504 questions
0
votes
0
answers
21
views
Understanding syntax of output from alias [duplicate]
I don't understand how to read the string and the escaping of the following output from listing aliases
> alias foo="echo 'hello'"
> alias
...
alias foo='echo '\''hello'\'''
...
It ...
0
votes
1
answer
61
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 ...
-1
votes
1
answer
45
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
5
votes
1
answer
455
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 ...
1
vote
1
answer
410
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 :
# ...
-1
votes
3
answers
101
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 ...
0
votes
0
answers
63
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: ...
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 ...
1
vote
1
answer
122
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 ...
2
votes
1
answer
325
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....
0
votes
1
answer
66
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:...
0
votes
1
answer
322
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
245
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 ...
5
votes
2
answers
611
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 ...
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 ...