Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have sentences with words that have a pattern such as p.G345L and p.X31Z. I need to remove p. so I get G345L and X31Z.

share|improve this question

3 Answers 3

Not sure what you have delimiting this, but you can easily pipe this through sed. With the GNU implementation of sed, in the pattern matching '\b' will denote a word boundary, which you can use to make sure you don't pick up part of a sentence, such as "stop."

$ cat file
p.G345L sentence stop.  p.X31Z part of another sentence
$ sed 's/\bp\.//g' file 
G345L sentence stop.  X31Z part of another sentence
share|improve this answer
    
Those sentences could exist in many text file in a directory, i need the file(s) to be updated –  user2957777 Jun 4 at 19:07
1  
@user2957777, use sed -i e.g. sed -i ..... *.txt. –  Cristian Ciupitu Jun 4 at 19:08

If the pattern is p. followed by an uppercase letter, followed by a sequence of one or more decimal digits followed by one uppercase letter, then that would be (POSIXly):

sed 's/p\.\([[:upper:]][[:digit:]]\{1,\}[[:upper:]]\)/\1/g'
share|improve this answer

You can do it many ways.

With perl:

$ echo "p.G345L and p.X31Z" | perl -pe 's/p\.//g'
G345L and X31Z

With sed:

$ echo "p.G345L and p.X31Z" | sed 's/p\.//g'
G345L and X31Z
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.