How to wrap a path with double quotes? [duplicate] - windows

This question already has answers here:
Use output of bash command (with pipe) as a parameter for another command
(4 answers)
When to wrap quotes around a shell variable?
(5 answers)
Closed 1 year ago.
I have the path of git --exec-path | sed 's#/#\\#g', I want to use explorer to open this path, like explorer "path", pseudocode: git --exec-path | sed 's#/#\\#g' | explorer "path", how to implement the last pipe?

Related

shell script Awk find and replace loop [duplicate]

This question already has answers here:
Shell script - search and replace text in multiple files using a list of strings
(5 answers)
Difference between single and double quotes in Bash
(7 answers)
When to wrap quotes around a shell variable?
(5 answers)
How do I use shell variables in an awk script?
(7 answers)
Closed 4 months ago.
I tried to find and replace certain strings in text file and the replace text contains "/" and sed commond did not work.
then I tried with awk command and it works fine with terminal with fixed variables.
but when I tried to use it with parameters in the loop it dose not work.
I have attached the code that I have write so far. could you please find me a solution.
this works find in terminal
awk '{sub(/input_image/,"https://www.abcd.com/images/XPDDL_R1_20161007.jpg")}1' format2.svg > format2.html
x=1
for param in ${paramO[#]}
do
awk '{sub(/${param}/,"${paramN[x]}")}1' $output_file > temp.txt
cp -rp temp.txt $output_file
let x=x+1
done

How to use sed command with variable [duplicate]

This question already has answers here:
Difference between single and double quotes in Bash
(7 answers)
How to use variables in a command in sed?
(4 answers)
Closed 5 months ago.
when I try to delete particular lines in my file using shellscrpit I use below command, It's not working, So can anyone help me on same.
sed -i '${lineNumber}d' <filename>

Replacing all backslash with double backslashes in bash [duplicate]

This question already has answers here:
Linux sed command - using variable with backslash
(2 answers)
Closed 1 year ago.
I'm trying to replace all \ with \\ in bash, I'm doing it like this but bash gets stuck in a never-ending loop. Where am I going wrong?
myVar="${myVar//\//\\\\}"
You can use sed for that:
echo "hello\world\hello\world" | sed 's/\\/\\\\/g'
Outputs:
hello\\world\\hello\\world

Why new line is added to variable at end? [duplicate]

This question already has answers here:
How to remove a newline from a string in Bash
(11 answers)
How to remove carriage return from a variable in shell script
(6 answers)
Closed 3 years ago.
file.sh
#!/bin/bash
fileName="Screenshot_$(TZ=GMT-3 date +%Y%m%d_%H%M%S).png"
echo "|$fileName|"
Terminal at Ubuntu 19.04:
> bash file.sh
|Screenshot_20190521_104141.png
|
I want to understand why a new-line is added to the variable at end?

How to use sed to append a line in bash script with a variable [duplicate]

This question already has answers here:
Use a variable's value in a sed command [duplicate]
(6 answers)
sed substitution with Bash variables
(6 answers)
Closed 4 years ago.
i am just trying to append a line from my bash script:
sed -i '$ a TEXT' "filename"
but when TEXT is a variable it does not work
sed -i '$ a $VARIABLE' "filename"
i have tested endless iterations with ',''," before/after $ and ${}, escape with \ etc., but i always get a literal $VARIABLE in my file
ps. please do not propose to use echo:)

Resources