Definitely I can tell you, what is the logic mistake in your code.
Your code is,
In your code,
s/\(\n>[^>]*\)_\([^>]*<\/\)/\1_Q\2/ this line substitutes _ to _Q from right side ( not from left side).
1. In the first iteration, it will substitute This_is_a_test to This_is_a_Qtest
2. In 2nd iteration, it will substitute This_is_a_Qtest to This_is_a_QQtest
3. In the third iteration, it will substitute This_is_a_QQtest to This_is_a_QQQtest
and it will go keep on like this, it never ends.....
This is the reason that your solution works when you replace only with Q, not with _Q.
You can see how the sed substitues,by executing the following code....
Hope this clarifies your question...
Thanks for the explanations and sample script showing that I was creating an infinite loop!
I'm not sure if I need to start a new thread, but I noticed that the code suggested is unable to accomplish the task if the second tag is on a new line. For example:
Do I need to have separate sed lines: one to find cases that fit the normal model where the start and end tags are on the same line and a second sed command that looks for those instances in which the line contains a start tag but ends with a newline character?
---------- Post updated 09-17-09 at 11:33 AM ---------- Previous update was 09-16-09 at 05:14 PM ----------
This may not be very elegant, but it seems to work:
I have a csv dataset like this :
C,rs18768
G,rs13785
GA,rs1065
G,rs1801279
T,rs9274407
A,rs730012
I'm thinking of use like awk, sed to covert the dataset to this format: (if it's two character, then keep the same)
CC,rs18768
GG,rs13785
GA,rs1065
GG,rs1801279
TT,rs9274407... (7 Replies)
Hello is it possible with awk or sed to replace any white space with the previous line characters in the same position?
I am asking this because the file I have doesn't always follow a pattern.
For example the file I have is the result of a command to obtain windows ACLs:
icacls C:\ /t... (5 Replies)
Hi,
Anyone can help using SED searches a character string for a specified delimiter character, and returns a leading or trailing space/blank.
Text file :
"1"|"ExternalClassDEA519CF5"|"Art1"
"2"|"ExternalClass563EA516C"|"Art3"
"3"|"ExternalClass305ED16B8"|"Art9"
...
...
... (2 Replies)
Hi there,
A total sed noob here. Is there a way using sed to delete everything before a character AND after another character on each line in a file? The deletion should also delete the indicating characters(here: an opening and a closing parenthesis).
The original file would look like... (3 Replies)
I am a newbie and would like some help with the following -
Trying to search fileA for a string similar to -
AS11000022010 30.4 31.7 43.7 53.8 60.5 71.1 75.2 74.7 66.9 56.6 42.7 32.5 53.3
I then want to replace that string with a string from fileB - ... (5 Replies)
Hi All,
Was wondering how I can do the following....
I have a String as follows
"ACCTRL000005022RRWDKKEEDKDD...."
This string can be in a file called tail.out or in a Variable called $VAR2
Now I have another variable called $VAR1="000004785" (9 bytes long), I need the content of... (5 Replies)
Hi all
I am trying to get my head around doing the following....
I have an input field that could contain either a number a blank field or a whitespace field.
What I want to do is delete a 0 (zero) if it's on its own or leading the number.
So:-
\t0 delete the zero
0 delete the... (8 Replies)
Hi
I need to write a script that read a input file that had same statement repeatedly to replace only 2nd & 5th time repeated statements (ex: This is UNIX forum) with another statement ( UNIX forum threads in Shell programming) with out modifying 1st,3,4th repeated statements. I am planning to do... (2 Replies)
It's all in the subject. I try to figure out how to repeat a character a number of time with printf.
For example to draw a line in a script output.
Thks (13 Replies)
I built a 12 million record file and made a mistake, one field is 1 character too long.
The record is 40 bytes and ends always in 999. I am trying to delete the 37 character in each record. Is this possible without doing a cut and paste. (1 Reply)