Replacing with a word in a file
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I would like to change </div>
in a very long document almost, consists of almost 2500 pages, with the word "Index:", but it never worked. I tried sed
in many different ways for example:
sed '/s^[</div>]/Index:/g'
But it didn't work!
would you please let me know what is the correct command?
example
</div>
</div>
<script src="https://cdn.pkgs.org/assets/js/main.min.js?v10"></script>
<script>
$(document).ready(function () </div>
app.init("pkgs.org", 101);
)
</div>
</script>
</body>
i want it
Index:
Index:
<script src="https://cdn.pkgs.org/assets/js/main.min.js?v10"></script>
<script>
$(document).ready(function () Index
app.init("pkgs.org", 101);
)
Index:
</script>
</body>
bash
add a comment |Â
up vote
3
down vote
favorite
I would like to change </div>
in a very long document almost, consists of almost 2500 pages, with the word "Index:", but it never worked. I tried sed
in many different ways for example:
sed '/s^[</div>]/Index:/g'
But it didn't work!
would you please let me know what is the correct command?
example
</div>
</div>
<script src="https://cdn.pkgs.org/assets/js/main.min.js?v10"></script>
<script>
$(document).ready(function () </div>
app.init("pkgs.org", 101);
)
</div>
</script>
</body>
i want it
Index:
Index:
<script src="https://cdn.pkgs.org/assets/js/main.min.js?v10"></script>
<script>
$(document).ready(function () Index
app.init("pkgs.org", 101);
)
Index:
</script>
</body>
bash
1
Please provide sample input and output, and thesed
examples you tried. Note that, ingeneral, parsing HTML is not a good idea
â Jeff Schaller
1 hour ago
it is not html, we clean this document frome very extra charcters we only has </div> and cant moe it out the book
â Zahi
1 hour ago
Downvoters, what is wrong with this question? It is very clear in what it wants to achieve, and what the OP has done to try and solve the problem. If you believe there to be some issue, please tell the OP in the comments. That's what they're for.
â Cyclic3
15 mins ago
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I would like to change </div>
in a very long document almost, consists of almost 2500 pages, with the word "Index:", but it never worked. I tried sed
in many different ways for example:
sed '/s^[</div>]/Index:/g'
But it didn't work!
would you please let me know what is the correct command?
example
</div>
</div>
<script src="https://cdn.pkgs.org/assets/js/main.min.js?v10"></script>
<script>
$(document).ready(function () </div>
app.init("pkgs.org", 101);
)
</div>
</script>
</body>
i want it
Index:
Index:
<script src="https://cdn.pkgs.org/assets/js/main.min.js?v10"></script>
<script>
$(document).ready(function () Index
app.init("pkgs.org", 101);
)
Index:
</script>
</body>
bash
I would like to change </div>
in a very long document almost, consists of almost 2500 pages, with the word "Index:", but it never worked. I tried sed
in many different ways for example:
sed '/s^[</div>]/Index:/g'
But it didn't work!
would you please let me know what is the correct command?
example
</div>
</div>
<script src="https://cdn.pkgs.org/assets/js/main.min.js?v10"></script>
<script>
$(document).ready(function () </div>
app.init("pkgs.org", 101);
)
</div>
</script>
</body>
i want it
Index:
Index:
<script src="https://cdn.pkgs.org/assets/js/main.min.js?v10"></script>
<script>
$(document).ready(function () Index
app.init("pkgs.org", 101);
)
Index:
</script>
</body>
bash
bash
edited 57 mins ago
asked 1 hour ago
Zahi
1307
1307
1
Please provide sample input and output, and thesed
examples you tried. Note that, ingeneral, parsing HTML is not a good idea
â Jeff Schaller
1 hour ago
it is not html, we clean this document frome very extra charcters we only has </div> and cant moe it out the book
â Zahi
1 hour ago
Downvoters, what is wrong with this question? It is very clear in what it wants to achieve, and what the OP has done to try and solve the problem. If you believe there to be some issue, please tell the OP in the comments. That's what they're for.
â Cyclic3
15 mins ago
add a comment |Â
1
Please provide sample input and output, and thesed
examples you tried. Note that, ingeneral, parsing HTML is not a good idea
â Jeff Schaller
1 hour ago
it is not html, we clean this document frome very extra charcters we only has </div> and cant moe it out the book
â Zahi
1 hour ago
Downvoters, what is wrong with this question? It is very clear in what it wants to achieve, and what the OP has done to try and solve the problem. If you believe there to be some issue, please tell the OP in the comments. That's what they're for.
â Cyclic3
15 mins ago
1
1
Please provide sample input and output, and the
sed
examples you tried. Note that, ingeneral, parsing HTML is not a good ideaâ Jeff Schaller
1 hour ago
Please provide sample input and output, and the
sed
examples you tried. Note that, ingeneral, parsing HTML is not a good ideaâ Jeff Schaller
1 hour ago
it is not html, we clean this document frome very extra charcters we only has </div> and cant moe it out the book
â Zahi
1 hour ago
it is not html, we clean this document frome very extra charcters we only has </div> and cant moe it out the book
â Zahi
1 hour ago
Downvoters, what is wrong with this question? It is very clear in what it wants to achieve, and what the OP has done to try and solve the problem. If you believe there to be some issue, please tell the OP in the comments. That's what they're for.
â Cyclic3
15 mins ago
Downvoters, what is wrong with this question? It is very clear in what it wants to achieve, and what the OP has done to try and solve the problem. If you believe there to be some issue, please tell the OP in the comments. That's what they're for.
â Cyclic3
15 mins ago
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
7
down vote
accepted
If you remove the square brackets, escape the slash before the div>
, move the slash before the s to after it, and remove the caret, the regex works:
sed 's/</div>/Index:/g'
@Shervan A slash managed to sneak in when I wasn't looking! I have fixed this.
â Cyclic3
20 mins ago
@Shervan yes it is perfect thank you Cyclic3
â Zahi
16 mins ago
add a comment |Â
up vote
2
down vote
I see three problems:
The syntax of your sed command is wrong. I believe what you meant was the search and replace command, so the 's' must come before the slash:
sed 's/^[</div>]/Index:/g'
The fact that your string has the slash ('/') character in your search string messes up with sed. So you could either escape the slash with a backslash:
sed 's/^[</div>]/Index:/g'
or use another character as separator:
sed 's|^[</div>]|Index:|g'
You are using square brackets (
[</div>]
) in your search, which is not what you want. This expression matches any of the characters inside the square brackets once. Try the following command without square brackets:sed 's|^</div>|Index:|g'
Could the anonymous downvoters please leave some feedback?
â Cyclic3
20 mins ago
1
Yeah, this is really disappointing, taking the time to answer a question and getting downvoted without an explanation.
â Marcelo Roberto Jimenez
18 mins ago
It appears that the whole question, and answers too, have been downvoted.
â Cyclic3
16 mins ago
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
7
down vote
accepted
If you remove the square brackets, escape the slash before the div>
, move the slash before the s to after it, and remove the caret, the regex works:
sed 's/</div>/Index:/g'
@Shervan A slash managed to sneak in when I wasn't looking! I have fixed this.
â Cyclic3
20 mins ago
@Shervan yes it is perfect thank you Cyclic3
â Zahi
16 mins ago
add a comment |Â
up vote
7
down vote
accepted
If you remove the square brackets, escape the slash before the div>
, move the slash before the s to after it, and remove the caret, the regex works:
sed 's/</div>/Index:/g'
@Shervan A slash managed to sneak in when I wasn't looking! I have fixed this.
â Cyclic3
20 mins ago
@Shervan yes it is perfect thank you Cyclic3
â Zahi
16 mins ago
add a comment |Â
up vote
7
down vote
accepted
up vote
7
down vote
accepted
If you remove the square brackets, escape the slash before the div>
, move the slash before the s to after it, and remove the caret, the regex works:
sed 's/</div>/Index:/g'
If you remove the square brackets, escape the slash before the div>
, move the slash before the s to after it, and remove the caret, the regex works:
sed 's/</div>/Index:/g'
edited 21 mins ago
answered 49 mins ago
Cyclic3
580114
580114
@Shervan A slash managed to sneak in when I wasn't looking! I have fixed this.
â Cyclic3
20 mins ago
@Shervan yes it is perfect thank you Cyclic3
â Zahi
16 mins ago
add a comment |Â
@Shervan A slash managed to sneak in when I wasn't looking! I have fixed this.
â Cyclic3
20 mins ago
@Shervan yes it is perfect thank you Cyclic3
â Zahi
16 mins ago
@Shervan A slash managed to sneak in when I wasn't looking! I have fixed this.
â Cyclic3
20 mins ago
@Shervan A slash managed to sneak in when I wasn't looking! I have fixed this.
â Cyclic3
20 mins ago
@Shervan yes it is perfect thank you Cyclic3
â Zahi
16 mins ago
@Shervan yes it is perfect thank you Cyclic3
â Zahi
16 mins ago
add a comment |Â
up vote
2
down vote
I see three problems:
The syntax of your sed command is wrong. I believe what you meant was the search and replace command, so the 's' must come before the slash:
sed 's/^[</div>]/Index:/g'
The fact that your string has the slash ('/') character in your search string messes up with sed. So you could either escape the slash with a backslash:
sed 's/^[</div>]/Index:/g'
or use another character as separator:
sed 's|^[</div>]|Index:|g'
You are using square brackets (
[</div>]
) in your search, which is not what you want. This expression matches any of the characters inside the square brackets once. Try the following command without square brackets:sed 's|^</div>|Index:|g'
Could the anonymous downvoters please leave some feedback?
â Cyclic3
20 mins ago
1
Yeah, this is really disappointing, taking the time to answer a question and getting downvoted without an explanation.
â Marcelo Roberto Jimenez
18 mins ago
It appears that the whole question, and answers too, have been downvoted.
â Cyclic3
16 mins ago
add a comment |Â
up vote
2
down vote
I see three problems:
The syntax of your sed command is wrong. I believe what you meant was the search and replace command, so the 's' must come before the slash:
sed 's/^[</div>]/Index:/g'
The fact that your string has the slash ('/') character in your search string messes up with sed. So you could either escape the slash with a backslash:
sed 's/^[</div>]/Index:/g'
or use another character as separator:
sed 's|^[</div>]|Index:|g'
You are using square brackets (
[</div>]
) in your search, which is not what you want. This expression matches any of the characters inside the square brackets once. Try the following command without square brackets:sed 's|^</div>|Index:|g'
Could the anonymous downvoters please leave some feedback?
â Cyclic3
20 mins ago
1
Yeah, this is really disappointing, taking the time to answer a question and getting downvoted without an explanation.
â Marcelo Roberto Jimenez
18 mins ago
It appears that the whole question, and answers too, have been downvoted.
â Cyclic3
16 mins ago
add a comment |Â
up vote
2
down vote
up vote
2
down vote
I see three problems:
The syntax of your sed command is wrong. I believe what you meant was the search and replace command, so the 's' must come before the slash:
sed 's/^[</div>]/Index:/g'
The fact that your string has the slash ('/') character in your search string messes up with sed. So you could either escape the slash with a backslash:
sed 's/^[</div>]/Index:/g'
or use another character as separator:
sed 's|^[</div>]|Index:|g'
You are using square brackets (
[</div>]
) in your search, which is not what you want. This expression matches any of the characters inside the square brackets once. Try the following command without square brackets:sed 's|^</div>|Index:|g'
I see three problems:
The syntax of your sed command is wrong. I believe what you meant was the search and replace command, so the 's' must come before the slash:
sed 's/^[</div>]/Index:/g'
The fact that your string has the slash ('/') character in your search string messes up with sed. So you could either escape the slash with a backslash:
sed 's/^[</div>]/Index:/g'
or use another character as separator:
sed 's|^[</div>]|Index:|g'
You are using square brackets (
[</div>]
) in your search, which is not what you want. This expression matches any of the characters inside the square brackets once. Try the following command without square brackets:sed 's|^</div>|Index:|g'
answered 30 mins ago
Marcelo Roberto Jimenez
474
474
Could the anonymous downvoters please leave some feedback?
â Cyclic3
20 mins ago
1
Yeah, this is really disappointing, taking the time to answer a question and getting downvoted without an explanation.
â Marcelo Roberto Jimenez
18 mins ago
It appears that the whole question, and answers too, have been downvoted.
â Cyclic3
16 mins ago
add a comment |Â
Could the anonymous downvoters please leave some feedback?
â Cyclic3
20 mins ago
1
Yeah, this is really disappointing, taking the time to answer a question and getting downvoted without an explanation.
â Marcelo Roberto Jimenez
18 mins ago
It appears that the whole question, and answers too, have been downvoted.
â Cyclic3
16 mins ago
Could the anonymous downvoters please leave some feedback?
â Cyclic3
20 mins ago
Could the anonymous downvoters please leave some feedback?
â Cyclic3
20 mins ago
1
1
Yeah, this is really disappointing, taking the time to answer a question and getting downvoted without an explanation.
â Marcelo Roberto Jimenez
18 mins ago
Yeah, this is really disappointing, taking the time to answer a question and getting downvoted without an explanation.
â Marcelo Roberto Jimenez
18 mins ago
It appears that the whole question, and answers too, have been downvoted.
â Cyclic3
16 mins ago
It appears that the whole question, and answers too, have been downvoted.
â Cyclic3
16 mins ago
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%2f472412%2freplacing-div-with-a-word-in-a-file%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
Please provide sample input and output, and the
sed
examples you tried. Note that, ingeneral, parsing HTML is not a good ideaâ Jeff Schaller
1 hour ago
it is not html, we clean this document frome very extra charcters we only has </div> and cant moe it out the book
â Zahi
1 hour ago
Downvoters, what is wrong with this question? It is very clear in what it wants to achieve, and what the OP has done to try and solve the problem. If you believe there to be some issue, please tell the OP in the comments. That's what they're for.
â Cyclic3
15 mins ago