All Questions
84
questions
0
votes
1
answer
43
views
Replace string ${FOO} by ${'$'}{BAR} with sed
I have this string occurring N times in a file: ${FOO}
that I have to replace by this string: ${'$'}{BAR}
This is my current state:
sed "s/\\${FOO}/\\${'\\$'}{BAR}/" file.txt but it raises &...
1
vote
2
answers
915
views
Sed can not replace when string contains double quotes
Output error from the execution of sed command:
sed: -e expression #1, char 14: unterminated `s' command
command file that I am trying to execute:
#!/bin/sh
old_version='\"version\": \&...
1
vote
1
answer
435
views
How to insert ESC control characters in a file in FreeBSD?
I want to enclose Fortran comments with two escape commands (ESC+E and ESC+F).
This implies detecting the comment that begins with ! until end of line, and prefixing it with ESC+E and suffixing it ...
0
votes
1
answer
90
views
Putting single quote in the begining of column
I have a .txt file with publications for which columns are separated by a single space.
However, titles also have spaces an in order to separate the columns correctly I need to have all titles in ...
0
votes
1
answer
182
views
How to set sed command correctly
When I try following commands, (I'd like to rewrite sql).
Day='2020/12/1'
Dir=/home/test/data
sql=`cat $Dir"/"$test".sql" | sed -e "s/Day/$Day/g"`
I suffered following ...
3
votes
1
answer
9k
views
Escaping backlash and double quotes inside a sed expression (surrounded by double quotes)
$ echo 'output: " ' | sed "s/\"/\"/"
output: "
$ echo 'output: " ' | sed "s/\"/\\\"/"
output: "
$ echo 'output: " ' | sed "s/\&...
0
votes
1
answer
69
views
Printing all lines between two strings, with one as a user input, using sed [duplicate]
I'm trying to use:
sed -n '/String1/,/String2/p' Filename
to print all lines between String1 and String2. Although I want to add String1 as a user input so,
read $userinput
sed -n '/$userinput/,/...
1
vote
1
answer
505
views
sed bash script is unexpectedly replacing character with space instead of newline [duplicate]
Using bash command syntax:
echo "The*quick*brown*fox"|sed s/*/\\n/g
I get the desired output:
The
quick
brown
fox
However in script:
IN_TXT="The*quick*brown*fox"
OUT_TXT=$(echo $IN_TXT|sed s/*/\\...
0
votes
2
answers
731
views
Sed(?) is stripping backslash character from quote
I'm replacing a string with another string that includes escaped quotes:
echo "replace FOO" | sed -e "s~FOO~test\\\"test~g"
What I would expect is to see replace test\"test. Instead I see replace ...
2
votes
1
answer
24k
views
Replacing '\'' with sed
I want to replace '\'' in a text file to another word or character using sed command.
Tried using sed "s/'\''/×/g" but it doesn't work.
Anyone know the solution?
0
votes
1
answer
656
views
how to use quotes in sed & ssh?
i cant get this to work in bash/rhel 7:
ssh host "sed -i -e \"s/dnl MASQUERADE_AS.*\$/MASQUERADE_AS(\`domain.com\')dnl/\" /etc/mail/sendmail.mc"
bash: -c: line 0: unexpected EOF while looking for ...
0
votes
2
answers
2k
views
How can I pipe sed output to printf for formating?
I am using Tecplot to process wind tunnel data, but the input for Tecplot requires a specific format for variable specification; each variable is bracketed by double quotes "Variable Name". The ...
4
votes
2
answers
20k
views
Escaping ' (single quote) in sed replace string [duplicate]
I have a script that I'm using to perform some iptables changes across servers. In the script I have a sed command to find a string and insert iptables rule before that line.
The problem I'm having ...
2
votes
1
answer
71
views
replace specific characters containing "\" character with sed
I would like to replace the following sentence "lw 2,\" with the sentence "lw 2" however I cannot do it with
sed -i 's|lw 2,\|lw 2|g' "filname"
I get the following error
sed: -e expression #1, char ...
1
vote
1
answer
2k
views
Convert JSON with raw characters in string
Had a problem with a tool that was generating illegal JSON.
Some of the JSON strings contained characters in the range 00-1f. So I wanted to convert these characters to correctly escaped valued \...