Use of sed with double quotation
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
Answering to this question:
I found the following situation with sed
version 4.2.2.
From this input:
send host-name = gethostname();
domain-name, domain-name-servers, domain-search, host-name,
# option host-name "andare.swiftmedia.com";
I want to remove the string "host-name" only from the second line, so the expected output is:
send host-name = gethostname();
domain-name, domain-name-servers, domain-search,
# option host-name "andare.swiftmedia.com";
Then I used the following command:
sed -e 's/" host-name,"//g' input_file
However, it won't remove the " host-name," string on input_file leaving it as it was.
If I don't use double quotation:
sed -e 's/ host-name,//g' input_file
It gives properly the expected output.
I thought that the correct way would be by using double quotation, but can't figure out why it's not working here.
sed string
add a comment |Â
up vote
2
down vote
favorite
Answering to this question:
I found the following situation with sed
version 4.2.2.
From this input:
send host-name = gethostname();
domain-name, domain-name-servers, domain-search, host-name,
# option host-name "andare.swiftmedia.com";
I want to remove the string "host-name" only from the second line, so the expected output is:
send host-name = gethostname();
domain-name, domain-name-servers, domain-search,
# option host-name "andare.swiftmedia.com";
Then I used the following command:
sed -e 's/" host-name,"//g' input_file
However, it won't remove the " host-name," string on input_file leaving it as it was.
If I don't use double quotation:
sed -e 's/ host-name,//g' input_file
It gives properly the expected output.
I thought that the correct way would be by using double quotation, but can't figure out why it's not working here.
sed string
1
see also mywiki.wooledge.org/Quotes
â Sundeep
Nov 28 '17 at 13:19
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
Answering to this question:
I found the following situation with sed
version 4.2.2.
From this input:
send host-name = gethostname();
domain-name, domain-name-servers, domain-search, host-name,
# option host-name "andare.swiftmedia.com";
I want to remove the string "host-name" only from the second line, so the expected output is:
send host-name = gethostname();
domain-name, domain-name-servers, domain-search,
# option host-name "andare.swiftmedia.com";
Then I used the following command:
sed -e 's/" host-name,"//g' input_file
However, it won't remove the " host-name," string on input_file leaving it as it was.
If I don't use double quotation:
sed -e 's/ host-name,//g' input_file
It gives properly the expected output.
I thought that the correct way would be by using double quotation, but can't figure out why it's not working here.
sed string
Answering to this question:
I found the following situation with sed
version 4.2.2.
From this input:
send host-name = gethostname();
domain-name, domain-name-servers, domain-search, host-name,
# option host-name "andare.swiftmedia.com";
I want to remove the string "host-name" only from the second line, so the expected output is:
send host-name = gethostname();
domain-name, domain-name-servers, domain-search,
# option host-name "andare.swiftmedia.com";
Then I used the following command:
sed -e 's/" host-name,"//g' input_file
However, it won't remove the " host-name," string on input_file leaving it as it was.
If I don't use double quotation:
sed -e 's/ host-name,//g' input_file
It gives properly the expected output.
I thought that the correct way would be by using double quotation, but can't figure out why it's not working here.
sed string
edited Nov 28 '17 at 11:38
asked Nov 28 '17 at 11:34
Zumo de Vidrio
1,277318
1,277318
1
see also mywiki.wooledge.org/Quotes
â Sundeep
Nov 28 '17 at 13:19
add a comment |Â
1
see also mywiki.wooledge.org/Quotes
â Sundeep
Nov 28 '17 at 13:19
1
1
see also mywiki.wooledge.org/Quotes
â Sundeep
Nov 28 '17 at 13:19
see also mywiki.wooledge.org/Quotes
â Sundeep
Nov 28 '17 at 13:19
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
6
down vote
accepted
The character "
is not special for the shell inside '
...'
. In fact, inside '
...'
no character is special for the shell; as a consequence, the "
characters are passed to sed
; and they are not special to sed
.
The command sed -e 's/" host-name,"//g'
is looking literally for "
Â
h
o
s
t
n
a
m
e
,
"
, which it won't find because it's not there.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
6
down vote
accepted
The character "
is not special for the shell inside '
...'
. In fact, inside '
...'
no character is special for the shell; as a consequence, the "
characters are passed to sed
; and they are not special to sed
.
The command sed -e 's/" host-name,"//g'
is looking literally for "
Â
h
o
s
t
n
a
m
e
,
"
, which it won't find because it's not there.
add a comment |Â
up vote
6
down vote
accepted
The character "
is not special for the shell inside '
...'
. In fact, inside '
...'
no character is special for the shell; as a consequence, the "
characters are passed to sed
; and they are not special to sed
.
The command sed -e 's/" host-name,"//g'
is looking literally for "
Â
h
o
s
t
n
a
m
e
,
"
, which it won't find because it's not there.
add a comment |Â
up vote
6
down vote
accepted
up vote
6
down vote
accepted
The character "
is not special for the shell inside '
...'
. In fact, inside '
...'
no character is special for the shell; as a consequence, the "
characters are passed to sed
; and they are not special to sed
.
The command sed -e 's/" host-name,"//g'
is looking literally for "
Â
h
o
s
t
n
a
m
e
,
"
, which it won't find because it's not there.
The character "
is not special for the shell inside '
...'
. In fact, inside '
...'
no character is special for the shell; as a consequence, the "
characters are passed to sed
; and they are not special to sed
.
The command sed -e 's/" host-name,"//g'
is looking literally for "
Â
h
o
s
t
n
a
m
e
,
"
, which it won't find because it's not there.
answered Nov 28 '17 at 11:43
AlexP
6,656924
6,656924
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f407479%2fuse-of-sed-with-double-quotation%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
see also mywiki.wooledge.org/Quotes
â Sundeep
Nov 28 '17 at 13:19