help with sed command
I'm new to shell programming and am trying to delete/replace certain characters in a pattern. Here's an example of what I'm trying to do.
input file has multiple lines of the following form
#0,v,g,n,n,n,(stuff....)
#1,x,g,n,c,n,(stuff..blah..blah)
#2,x,g,x,x,m,(stuff..blah)
...
#25,x,g,x,x,n,(stuff...)
and I want to output to be
#0,v,g,n,n,(stuff...)
#1,u,g,n,c,(stuff....)
#2,u,g,n,n,(stuff...)
.....
#25,u,g,n,n,(stuff....)
Basically I need to replace the first occurrence of x with u then the rest with n. This part I was able to do. Then I need to remove the last letter from the pattern (n or m) and leave the rest. Is there some way I can search for say ,.,.,.,.,., and then remove the last ., without knowing what character it will be or which occurrence. Say read the pattern into a variable and then remove the last character through its index or something.
Thanks for any help on figure this out
D