Replacing with a word in a file

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite
1












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 sedin 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>









share|improve this question



















  • 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














up vote
3
down vote

favorite
1












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 sedin 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>









share|improve this question



















  • 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












up vote
3
down vote

favorite
1









up vote
3
down vote

favorite
1






1





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 sedin 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>









share|improve this question















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 sedin 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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 57 mins ago

























asked 1 hour ago









Zahi

1307




1307







  • 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












  • 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







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










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'





share|improve this answer






















  • @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

















up vote
2
down vote













I see three problems:




  1. 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'




  2. 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'




  3. 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'







share|improve this answer




















  • 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











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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






























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'





share|improve this answer






















  • @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














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'





share|improve this answer






















  • @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












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'





share|improve this answer














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'






share|improve this answer














share|improve this answer



share|improve this answer








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
















  • @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












up vote
2
down vote













I see three problems:




  1. 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'




  2. 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'




  3. 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'







share|improve this answer




















  • 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















up vote
2
down vote













I see three problems:




  1. 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'




  2. 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'




  3. 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'







share|improve this answer




















  • 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













up vote
2
down vote










up vote
2
down vote









I see three problems:




  1. 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'




  2. 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'




  3. 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'







share|improve this answer












I see three problems:




  1. 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'




  2. 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'




  3. 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'








share|improve this answer












share|improve this answer



share|improve this answer










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

















  • 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


















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































Comments

Popular posts from this blog

Long meetings (6-7 hours a day): Being “babysat” by supervisor

Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

Confectionery