I need to replace a string in html sed is not working
up vote
0
down vote
favorite
Here is the code in the shell script I have used
sed 's/xyxx/$date1/' /u001/Scripts/abc.html > /u001/Scripts/abc.html
The code is trying to print HTML tags inside AWK command
nawk 'BEGIN{
FS=","
print "<HTML>""<HEAD>""<p>Hi All,<br><br>There are no cases closed on the"
print "xyxx that meet the criteria for submission</p>"
}
END{
print "<p>Regards,<br>Support Team</p></BODY></HTML>"
}
'
awk sed aix html
New contributor
add a comment |
up vote
0
down vote
favorite
Here is the code in the shell script I have used
sed 's/xyxx/$date1/' /u001/Scripts/abc.html > /u001/Scripts/abc.html
The code is trying to print HTML tags inside AWK command
nawk 'BEGIN{
FS=","
print "<HTML>""<HEAD>""<p>Hi All,<br><br>There are no cases closed on the"
print "xyxx that meet the criteria for submission</p>"
}
END{
print "<p>Regards,<br>Support Team</p></BODY></HTML>"
}
'
awk sed aix html
New contributor
You should state your desired result and the actual result.
– RalfFriedl
2 days ago
do u want to replacexyxx
with the value ofdate1
or just as$date1
?
– msp9011
2 days ago
I need to replace xyxx with value of date1 inside the file or can I use print command itself inside awk
– RAJESH A S
2 days ago
usesed -i
to edit files in place. Your command will not work, because redirections are done first. So you'll be ending up with an empty file.
– RoVo
2 days ago
Also, if you need variable replacement, you need to put the sed command in double quotes for bash to expand the variables.
– RoVo
2 days ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Here is the code in the shell script I have used
sed 's/xyxx/$date1/' /u001/Scripts/abc.html > /u001/Scripts/abc.html
The code is trying to print HTML tags inside AWK command
nawk 'BEGIN{
FS=","
print "<HTML>""<HEAD>""<p>Hi All,<br><br>There are no cases closed on the"
print "xyxx that meet the criteria for submission</p>"
}
END{
print "<p>Regards,<br>Support Team</p></BODY></HTML>"
}
'
awk sed aix html
New contributor
Here is the code in the shell script I have used
sed 's/xyxx/$date1/' /u001/Scripts/abc.html > /u001/Scripts/abc.html
The code is trying to print HTML tags inside AWK command
nawk 'BEGIN{
FS=","
print "<HTML>""<HEAD>""<p>Hi All,<br><br>There are no cases closed on the"
print "xyxx that meet the criteria for submission</p>"
}
END{
print "<p>Regards,<br>Support Team</p></BODY></HTML>"
}
'
awk sed aix html
awk sed aix html
New contributor
New contributor
edited 2 days ago
Jeff Schaller
36.3k952120
36.3k952120
New contributor
asked 2 days ago
RAJESH A S
11
11
New contributor
New contributor
You should state your desired result and the actual result.
– RalfFriedl
2 days ago
do u want to replacexyxx
with the value ofdate1
or just as$date1
?
– msp9011
2 days ago
I need to replace xyxx with value of date1 inside the file or can I use print command itself inside awk
– RAJESH A S
2 days ago
usesed -i
to edit files in place. Your command will not work, because redirections are done first. So you'll be ending up with an empty file.
– RoVo
2 days ago
Also, if you need variable replacement, you need to put the sed command in double quotes for bash to expand the variables.
– RoVo
2 days ago
add a comment |
You should state your desired result and the actual result.
– RalfFriedl
2 days ago
do u want to replacexyxx
with the value ofdate1
or just as$date1
?
– msp9011
2 days ago
I need to replace xyxx with value of date1 inside the file or can I use print command itself inside awk
– RAJESH A S
2 days ago
usesed -i
to edit files in place. Your command will not work, because redirections are done first. So you'll be ending up with an empty file.
– RoVo
2 days ago
Also, if you need variable replacement, you need to put the sed command in double quotes for bash to expand the variables.
– RoVo
2 days ago
You should state your desired result and the actual result.
– RalfFriedl
2 days ago
You should state your desired result and the actual result.
– RalfFriedl
2 days ago
do u want to replace
xyxx
with the value of date1
or just as $date1
?– msp9011
2 days ago
do u want to replace
xyxx
with the value of date1
or just as $date1
?– msp9011
2 days ago
I need to replace xyxx with value of date1 inside the file or can I use print command itself inside awk
– RAJESH A S
2 days ago
I need to replace xyxx with value of date1 inside the file or can I use print command itself inside awk
– RAJESH A S
2 days ago
use
sed -i
to edit files in place. Your command will not work, because redirections are done first. So you'll be ending up with an empty file.– RoVo
2 days ago
use
sed -i
to edit files in place. Your command will not work, because redirections are done first. So you'll be ending up with an empty file.– RoVo
2 days ago
Also, if you need variable replacement, you need to put the sed command in double quotes for bash to expand the variables.
– RoVo
2 days ago
Also, if you need variable replacement, you need to put the sed command in double quotes for bash to expand the variables.
– RoVo
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
In this command,
sed 's/xyxx/$date1/' /u001/Scripts/abc.html > /u001/Scripts/abc.html
the redirection happens first! So the shell opens /u001/Scripts/abc.html
for writing and empties it. Then the sed
command runs, but the input file is empty, so no output either.
As the comments suggest, you should use:
sed -i.bak 's/xyxx/'"$date1"'/' /u001/Scripts/abc.html
which will
- create a backup file with extension
.bak
and overwrite the original file (-i.bak
) - and use the variable value of
$date1
, because it's put in double quotes, unlike the rest of thesed
expression.
New contributor
I am unable to get the output on the mentioned command above sed -i.bak 's/xyxx/'"$date1"'/' /u001/Scripts/abc.html
– RAJESH A S
yesterday
make sure that$date1
does not contain characters that are interpreted bysed
, e.g. a slash or an@
will cause problems.
– RoVo
yesterday
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
In this command,
sed 's/xyxx/$date1/' /u001/Scripts/abc.html > /u001/Scripts/abc.html
the redirection happens first! So the shell opens /u001/Scripts/abc.html
for writing and empties it. Then the sed
command runs, but the input file is empty, so no output either.
As the comments suggest, you should use:
sed -i.bak 's/xyxx/'"$date1"'/' /u001/Scripts/abc.html
which will
- create a backup file with extension
.bak
and overwrite the original file (-i.bak
) - and use the variable value of
$date1
, because it's put in double quotes, unlike the rest of thesed
expression.
New contributor
I am unable to get the output on the mentioned command above sed -i.bak 's/xyxx/'"$date1"'/' /u001/Scripts/abc.html
– RAJESH A S
yesterday
make sure that$date1
does not contain characters that are interpreted bysed
, e.g. a slash or an@
will cause problems.
– RoVo
yesterday
add a comment |
up vote
1
down vote
In this command,
sed 's/xyxx/$date1/' /u001/Scripts/abc.html > /u001/Scripts/abc.html
the redirection happens first! So the shell opens /u001/Scripts/abc.html
for writing and empties it. Then the sed
command runs, but the input file is empty, so no output either.
As the comments suggest, you should use:
sed -i.bak 's/xyxx/'"$date1"'/' /u001/Scripts/abc.html
which will
- create a backup file with extension
.bak
and overwrite the original file (-i.bak
) - and use the variable value of
$date1
, because it's put in double quotes, unlike the rest of thesed
expression.
New contributor
I am unable to get the output on the mentioned command above sed -i.bak 's/xyxx/'"$date1"'/' /u001/Scripts/abc.html
– RAJESH A S
yesterday
make sure that$date1
does not contain characters that are interpreted bysed
, e.g. a slash or an@
will cause problems.
– RoVo
yesterday
add a comment |
up vote
1
down vote
up vote
1
down vote
In this command,
sed 's/xyxx/$date1/' /u001/Scripts/abc.html > /u001/Scripts/abc.html
the redirection happens first! So the shell opens /u001/Scripts/abc.html
for writing and empties it. Then the sed
command runs, but the input file is empty, so no output either.
As the comments suggest, you should use:
sed -i.bak 's/xyxx/'"$date1"'/' /u001/Scripts/abc.html
which will
- create a backup file with extension
.bak
and overwrite the original file (-i.bak
) - and use the variable value of
$date1
, because it's put in double quotes, unlike the rest of thesed
expression.
New contributor
In this command,
sed 's/xyxx/$date1/' /u001/Scripts/abc.html > /u001/Scripts/abc.html
the redirection happens first! So the shell opens /u001/Scripts/abc.html
for writing and empties it. Then the sed
command runs, but the input file is empty, so no output either.
As the comments suggest, you should use:
sed -i.bak 's/xyxx/'"$date1"'/' /u001/Scripts/abc.html
which will
- create a backup file with extension
.bak
and overwrite the original file (-i.bak
) - and use the variable value of
$date1
, because it's put in double quotes, unlike the rest of thesed
expression.
New contributor
New contributor
answered 2 days ago
Arcticooling
584
584
New contributor
New contributor
I am unable to get the output on the mentioned command above sed -i.bak 's/xyxx/'"$date1"'/' /u001/Scripts/abc.html
– RAJESH A S
yesterday
make sure that$date1
does not contain characters that are interpreted bysed
, e.g. a slash or an@
will cause problems.
– RoVo
yesterday
add a comment |
I am unable to get the output on the mentioned command above sed -i.bak 's/xyxx/'"$date1"'/' /u001/Scripts/abc.html
– RAJESH A S
yesterday
make sure that$date1
does not contain characters that are interpreted bysed
, e.g. a slash or an@
will cause problems.
– RoVo
yesterday
I am unable to get the output on the mentioned command above sed -i.bak 's/xyxx/'"$date1"'/' /u001/Scripts/abc.html
– RAJESH A S
yesterday
I am unable to get the output on the mentioned command above sed -i.bak 's/xyxx/'"$date1"'/' /u001/Scripts/abc.html
– RAJESH A S
yesterday
make sure that
$date1
does not contain characters that are interpreted by sed
, e.g. a slash or an @
will cause problems.– RoVo
yesterday
make sure that
$date1
does not contain characters that are interpreted by sed
, e.g. a slash or an @
will cause problems.– RoVo
yesterday
add a comment |
RAJESH A S is a new contributor. Be nice, and check out our Code of Conduct.
RAJESH A S is a new contributor. Be nice, and check out our Code of Conduct.
RAJESH A S is a new contributor. Be nice, and check out our Code of Conduct.
RAJESH A S is a new contributor. Be nice, and check out our Code of Conduct.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f483132%2fi-need-to-replace-a-string-in-html-sed-is-not-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You should state your desired result and the actual result.
– RalfFriedl
2 days ago
do u want to replace
xyxx
with the value ofdate1
or just as$date1
?– msp9011
2 days ago
I need to replace xyxx with value of date1 inside the file or can I use print command itself inside awk
– RAJESH A S
2 days ago
use
sed -i
to edit files in place. Your command will not work, because redirections are done first. So you'll be ending up with an empty file.– RoVo
2 days ago
Also, if you need variable replacement, you need to put the sed command in double quotes for bash to expand the variables.
– RoVo
2 days ago