All Questions
6
questions
2
votes
2
answers
220
views
shell variable test expansion problem
I have this code:
sed \
$( (( $compress == 1 )) && echo -n '-e /^RMTHOST/ s/$/, compress/' ) \
-e "s|\*\*jobname\*\*|$jobname|g" \
-e "s|\*\*hostname\*\*|$hostname|g" \
-e "s|\*\*hostport\*\*|...
0
votes
1
answer
640
views
Do I need to double quote a variable?
I am confused on when we double quote shell variables.
Specifically I am using the following sed replace command:
sed -i.tmp "/$MY_VAR/d" /foo/bar/file.txt
But I am not quoting $MY_VAR. Is this ...
2
votes
5
answers
92
views
Editing a sed statement
I'm writing a script to change on the fly the firefox home page through a text variable:
sed -i 's|\("browser.startup.homepage",\) "\(.*\)"|\1 "$ddrs"|' /home/max/.mozilla/firefox/*.default/prefs.js
...
4
votes
2
answers
2k
views
Replace string in a file with another where both are saved in variables
I want to replace a string found in a file with another string, but both have a special character (in this example it is a . char) e.g 1.0 and 2.0.
So this is the command currently used:
sed -i 's/1\...
2
votes
3
answers
2k
views
sed won't expand my BASH variable in script
I have this script, which will prompt for the relative or absolute path to the file and then swap whitespaces ' ' with '\ ' which works in Linux console. Substitution is done using the first sed ...
4
votes
5
answers
30k
views
How to use a shell variable inside sed's s command? [duplicate]
we know that we can get the value of a variable using $ sign:
x=3
echo $x
3
Is there other ways that we can use to get the value without using $ sign.
I'm asking this because $ sign is a special ...