0

I have a document and I want to remove all the patterns so that I stay with only some information, the producer/creator of that document.

I managed to replace patterns with one word "PATTERN" so that it becomes easy to remove them. How can I remove this word? Here are the commands I used:

$ cat /path | tr \n \f | \
  tr -cd "[A-Za-z0-9 () /\f] | \
  sed s/stream.*endstream/STREAM/ | sed s/[0-9][0-9]* /PATTERN/g | \
  sed "s/PATTERN PATTERN n/PTR/g"

I obtain this

/rdfRDF/xxmpmetaxpacket efdwefdstreamefdobjPATTERN PATTERN obj/DisplayDocTitle trueefdobjPATTERN PATTERN obj/Type/XRef/Size PATTERN/W[ PATTERN PATTERN PATTERN] /Root PATTERN PATTERN R/Iffo PATTERN PATTERN R/ID[PATTERNFEFPATTERNCPATTERNEPATTERNDBPATTERNFPATTERNEPATTERNFPATTERNEEPATTERNFEFPATTERNCPATTERNEPATTERNDBPATTERNFPATTERNEPATTERNFPATTERNEEPATTERN] /Filter/FlateDecode/Lefgth PATTERNstreamxc Z)PATTERNBSekgPBB(FUfLqSuefdstreamefdobjxrefPATTERN PATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN fPATTERN PATTERN ftrailer/Size PATTERN/Root PATTERN PATTERN R/Iffo PATTERN PATTERN R/ID[PATTERNFEFPATTERNCPATTERNEPATTERNDBPATTERNFPATTERNEPATTERNFPATTERNEEPATTERNFEFPATTERNCPATTERNEPATTERNDBPATTERNFPATTERNEPATTERNFPATTERNEEPATTERN] startxrefPATTERNEOFxrefPATTERN PATTERNtrailer/Size PATTERN/Root PATTERN PATTERN R/Iffo PATTERN PATTERN R/ID[PATTERNFEFPATTERNCPATTERNEPATTERNDBPATTERNFPATTERNEPATTERNFPATTERNEEPATTERNFEFPATTERNCPATTERNEPATTERNDBPATTERNFPATTERNEPATTERNFPATTERNEEPATTERN] /Prev PATTERN/XRefStm PATTERNstartxrefPATTERNEOF

How to remove the word PATTERN?

  • 2
    This looks like an XY problem. What are you actually trying to do? Is the input data an RDF file? if not, what is it? – cas Aug 26 '19 at 2:09
  • you probably want to use exempi - this is a program designed for working with XMP data on the command line. e.g. you can use exempi -g <foo> to extract the value of an XMP property called "foo". I expect your difficulties are an object lesson in why you shouldn't try to process structured data like XML without using a proper parser (i.e. don't use only regexps to process XML). – cas Aug 26 '19 at 2:17
0

Try the following:

sed -i -e 's/PATTERN//g' filename

  • That is helpful, thanks. However, it seems that I also removed the producer of the document in my previous commands -$ cat /path | tr \n \f |tr -cd "[A-Za-z0-9 () /\f] | sed s/stream.endstream/STREAM/ | sed s/[0-9][0-9] /PATTERN/g | sed "s/PATTERN PATTERN n/PTR/g". – Lionel Aug 25 '19 at 15:02
  • How can I remove something like ((((((((((((((QEQEQEQEQEW using the sed command? – Lionel Aug 25 '19 at 20:12
  • @Lionel I have tried the following and it seems to work: sed -i -re 's/[(][(][(][(][(][(][(][(][(][(][(][(][(][(]QEQEQEQEQEW//g' filename – am401 Aug 27 '19 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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