Using sed in bash script to serach and replace special characters, and text
Hi guys. I want to run a bash script that searches for and replaces the following text/characters.:
:ns0 with :ll ns0: with ll: remove [position() >= 2] remove [1],[2],[3] up tp [9] <xsl:apply-templates select="ll: with <xsl:apply-templates select="/ll:WordML/ll:WordML/ll: I have been trying for a good couple of hours now, but i just cant get it right. I do not have a lot of experience in scripting/programming, so be nice :) Code:
#!/bin/bash As I said, not a programmer. If you know what's wrong, could you not just write the code, but maybe a short explanation too? Thanks heaps! |
Help us to help you. Provide a sample input file (10-15 lines will do). Construct a sample output file which corresponds to your sample input and post both samples here. With "Before and After" examples we can better understand your needs and also judge if our proposed solution fills those needs.
Daniel B. Martin |
This file.xsl
Code:
:ns0 with :ll Code:
#!/bin/bash Code:
:ll with :ll and [[] + []] looks like an optical illusion ,. I swear it is as it make no sense Ohh, and I strung them all together in one sed, using \ for line continuation ( so shell thinks all one line ) left off the -i, |
Thanks Firerat!
That's soo neat! Just discovered that the file contains [position() >= 3], [position() >= 4] and so on up to 9(did not see this, it's like 10000 lines of code). So i just did the same as with ns[0-9]. [position() >= [0-9]]. So the final code would be: Code:
#!/bin/bash Just 1 last question, why leave out -i? Is it just good "scripting manners"? Oh, sorry that I forgot to include some samples from the xsl file danielbmartin. |
Quote:
but I guess you test on a backup anyway.. and , talking of backup, -i.backup-ext-of-your-pref seeing as you have 10,000 lines, you could test with head or tail, e.g. tail -n 200 file.xsl | sed -e ..... just 'sample' last 200 lines |
Quote:
Code:
#!/bin/bash |
Thanks guys. really appreciate it! I'll keep you posted on my progress.
cheers |
All times are GMT -5. The time now is 01:16 PM. |