I have a file with multiple occurrences (more than 1000) of:

REF*SY*111111111, REF*SY*777777777, REF*SY*145485450...etc.

I need all the data be replaced with a standard output:

REF*SY*111111111,REF*SY*111111111, REF*SY*111111111 ....etc. 

Can I do it with sed or awk?

  • 1
    The answer is: yes, you can. Have you tried anything to solve your problem already? We won't give you solution, but we can help ypu if you will have any problem with your script – mrc02_kr Oct 25 '18 at 21:09
  • Welcome to U&L! We are a question-answering community, not a scriptwriting community. We're happy to help, but we're happy to help, not to just do your work for you, particularly without the sort of details we'd need to be able to assist you in this specific case. What have you tried? How did it not work as expected or intended? Can you show us an example of actual input, and what the actual desired output would be? – DopeGhoti Oct 25 '18 at 21:13
  • I'm unclear about what you're asking. Is it replace all digits with "1"? – glenn jackman Oct 25 '18 at 21:25

man sed is your friend here. Making a few assumptions, I guess these should work for you:

sed -e 's/REF\*SY\*[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/REF*SY*111111111/g'
perl -pe 's/REF\*SY\*[0-9]{9}REF*SY*111111111/g'
  • Thank you GarethHumphriesAcc. It Worked !!!! – R M Oct 26 '18 at 3:47

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