RE: automated editing of text files
Hi Camaleón,
>> I have a bunch of files where I need an extra line after a <pre> code.
>> So I need to change <pre>CRLF (or <pre>LF) to <pre>CRLFCRLF.
>>
>> Which toool can I use for that, I can't remember which tool is a good
>> one for this and google is no help.
>> I am not fluent in any of the programming languages but I do write bash
>> scripts.
> I bet you can do this with a bash script for looping into the text files
> and then replacing the text with "sed".
>
>Yep, something like this:
>
>http://www.cyberciti.biz/faq/unix-linux-replace-string-words-in-many-files/
By looking at my UnixUtils list which I have on my Windows machine I had found sed as well. :-)
Have been experimenting some with it but...
linbobo:~/sedtest# sed 's_<pre>_<post>_' <original.txt >new.txt
linbobo:~/sedtest# less new.txt
And indeed I will see <post> on that line instead of <pre> but...
linbobo:~/sedtest# sed 's_\n<pre>\n_\n<pre>\n\n_' <original.txt >new.txt
linbobo:~/sedtest# less new.txt
Will not create a new line after <pre> :-(
Bonno
Reply to: