2

So I have a log.txt files which I can search in Notepad++ on Windows, however due to the sheer number of them, I'd like to be able to run grep on them. However, the data is formatted with non-rendering characters which I don't know how to include in my grep. Notepad++ shows them as the black RS. The format of the data is like [RS]value1[RS]value2 and I need to be able to grep for value1 AND value2. This format is always constant throughout these files.

How can I make grep search for this? Is there some form of escape sequence I can use? Or should I just make it search for value1 and value2 and completely ignore the presence of this non-rendering character?

5
  • Can you please give an example input and the exact desired output? Is the data always like: [RS]value1[RS]value2?
    – chaos
    Commented Oct 16, 2015 at 10:35
  • Yeah it's always this format. The log is like Connection[RS]name[RS], so i wish for grep to return every line which has connection[RS]name[RS] on it.If i grep just for name i get a myriad of irrelevant results. Commented Oct 16, 2015 at 10:46
  • Then just grep "\[RS\]value1\[RS\]value2" file should do the job
    – chaos
    Commented Oct 16, 2015 at 10:52
  • The problem is the [RS] is what notepad++ sees it as, this charicter is actually a non-rendering record seperator, so i don't know how to pass it to grep. puu.sh/kMaVv/a90450e163.png this screenshot is of the charicter i am meaning. Commented Oct 16, 2015 at 10:54
  • 1
    probably '.value1.value2' or $'\1evalue1\x1evalue2' will work
    – adonis
    Commented Oct 16, 2015 at 11:09

1 Answer 1

4

Your [RS] = Record Separator[1] is a Record Separator character ASCII 30 0x1E

You can use this knowledge to grep for $'\x1e' (as suggested in comments) or if you want to be more general then use a character class like [^[:print:]] or [[:cntrl:]] to match it.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .