Skip to main content

All Questions

Tagged with
-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
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
3 votes
1 answer
280 views

Recursively renaming apostrophs ' in filenames (Bash)

Need to remove apostrophes from files. I have tried several approaches, also from Stackexchange. I am on a Synology NAS, so I don't have Python, or Perl and furthermore I have to exclude certain ...
Gary U.U. Unixuser's user avatar
0 votes
1 answer
382 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 ;; *) ...
noemata's user avatar
1 vote
1 answer
161 views

bash 'pattern substitution' fails only in some conditions

Why does/would the following printf statement behave differently based upon ...? (GNU bash, version 4.4.18(1)-release (x86_64-pc-linux-gnu)) printf "%s : %s : %s\n" $TERM ${TERM//[^[:alnum:]]/_} ${...
user1404316's user avatar
  • 3,098
1 vote
1 answer
610 views

Escaping bash variables before storing them in an apache hive database

I'm running a script file sqoop_import_ATM.sh and would like to store the logs in a SQL database. First thing I did was to direct the logs into my own variable: OUTPUT="$(/home/me/...
Greg Peckory's user avatar
4 votes
4 answers
18k views

Bash converting path names for sed so they escape [duplicate]

I'm having a problem with a script. It is meant to change a value in a file called %DIR% so that it becomes a path name. The problem is the slashes in the directory name upset sed, so I get weird ...
John Tate's user avatar
  • 1,990
6 votes
2 answers
20k views

How to escape single or double quotes when passing a variable to bash script?

Let's say I have a script which echoes $1 #!/bin/bash echo $1 It's called test.sh. Then I call /bin/test.sh 'test'. The output is test. But this doesn't work: /bin/test.sh 'te'st' There's a syntax ...
Pepa Vidlák's user avatar
1 vote
1 answer
5k views

Using sed to replace a string with special chars with another string with special characters

I'm trying to automate switching out a bash prompt for another in .bashrc Original String: PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' ...
daedalus's user avatar
5 votes
2 answers
7k views

Splitting the working directory in a bash script

If I do: IFS="/" read -ra PARTS And type in a path manually, it creates the array "PARTS" as hoped, however: IFS="/" read -ra PARTS <<< $(pwd) creates an array with a single element, with ...
Brent's user avatar
  • 214
3 votes
2 answers
7k views

Why quotes are retained in string variables when surrounded by single quotes?

I needed to retain the double quotes around a string variable defined in bash in order to be able to pass it to a dialect of the Scheme programming language. My question is why are the double quotes ...
Vesnog's user avatar
  • 679
10 votes
1 answer
869 views

Test -n gives unexpected result

I understand test -n <expression> to return false if the expression evaluates to a string length of greater than 0. Why then does the following happen? Macbook:~ echo ${#undeclared_variable} 0 ...
Gregg Leventhal's user avatar
6 votes
2 answers
2k views

how do I set quotes around a variable so that the programs sees them as quote marks

I am trying to get quotes around a variable to make is just like I typed it in the terminal to get this script to work. it shows " quotes around the varibale " but still does not see it as quotes, as ...
uxserx-bw's user avatar
  • 526
2 votes
4 answers
10k views

Appending a string containing escape character with sed

Currently I use: sed -i -e "5a\\ ${text}" $filename to append something to a certain line, where the variable text contains a string such as "\epsilon". When using echo -E $text the string is ...
pmr's user avatar
  • 123
2 votes
3 answers
393 views

How to pass lines from a file to a bash script, so that each line remains undivided, even if there are spaces?

Given: $ cat lines.txt a/b 'c/d e/f' $ cat 1.sh #!/bin/sh ./2.sh `cat lines.txt` $ cat 2.sh #!/bin/sh echo p1=$1 echo p2=$2 echo p3=$3 $ ./1.sh p1=a/b p2='c/d p3=e/f' How do I change lines.txt or ...
mark's user avatar
  • 379