1)In the first line i want to change from 18 position - 25 position to some other value- alpha numeric
2)if the line startd with 5900 then i should change 5 - 17 to some text
Simiar to other lines also ...with different positions
---------- Post updated at 01:55 AM ---------- Previous update was at 01:46 AM ----------
I have one more query in second part of sed
sed '/^5900/s/\(^.\{4\}\).\{13\}\(.*\)/\1some123text\2/' inputfile
How do i can insert another condition into the above command
Example:
in the same line i have to check wther the 30th position is R or S or V
i mean below is the condition
1)The should starts with 5900
2)The 30 position is R or S or V .. then i have to change to some text
--> '1s' refers to substitution only in the first line. First 17 characters (matched by pattern in green) are stored in buffer, referenced by \1. The next 8 characters (i.e. from char 18 through to 25, pattern in blue) are matched. Rest of the line (pattern in red) is stored in buffer, reference by \2. This whole thing is substituted by "\1some123text\2".
--> Pattern in green matches line starting with 5900. In such lines, first 4 characters (pattern in blue) are stored in buffer, referenced by \1. The next 13 characters (i.e. from char 5 through to 17, pattern in red) are matched. Rest of the line (pattern in pink) is stored in buffer, referenced by \2. This whole thing is substituted by "\1some123text\2".