---------- Post updated at 03:46 AM ---------- Previous update was at 03:35 AM ----------
suppose ther are 100 files. i need to remove the 888 segments for all the 100 at the end, and the date field is constant it always contains 12 digits,and i need 2 remove the last 4 digits in it, and replace it with "9899".
Is this possible with script??
---------- Post updated at 04:04 AM ---------- Previous update was at 03:51 AM ----------
INPUT:1_120606259532_3_4.5_888
if there any many inputs..in all the inputs the date length (bold) is constant ie 12 digits,i need 2 remove the last 4 digits in date field and replace with "9899" and finally the last segment in the file ie 888 needs to be removed.
s t possible??
---------- Post updated at 05:59 AM ---------- Previous update was at 04:04 AM ----------
by assigning some variable as 8899..and then substituting the date field,in the part of the script,is that possible.?
._ --> one char (first char) (1)
.\{8\}\ --> 8 chars
\( ........ \) --> save portion of our string for write in the RHS (cut and save it to buffer and it is equal to \1 [backreference numbered 1] ,
the sed structure is named "back reference headache(sed buffer) for after the write the stdoutput in the RHS[the right-hand side]
liitle expl --> sed 's/THIS/CHANGE/' --> LHS is the "THIS" in here and RHS is the "CHANGE")
.\{4\} --> remaining 4 chars from our string
so we get the ._ -> first char from string --> "1" and "_"
and 8 chars --> "12060625"
and 4 chars --> "9532"
\(._.\{8\}\) --> (\1 --> 1_12060625)
\(_.*\) --> "_3_4.5" (it is our back reference numbered 2 --> it expressed like --> \2)
_.* --> "_888"
and in the RHS(right-hand side sed 's/...../...../') we can the write that the our values
so ....../\1'$val'\2/
\1 --> 1_12060625
$val --> "9899"
\2 --> "_3_4.5"
result is "1_120606259899_3_4.5"