How to grep ASCII control character

If I have a file that contains an ASCII control character like ^A

(start of header).

How can I find it using grep on Linux?

+3


source to share


2 answers


As in the comments , this solved the problem:



grep $'\01' file

      

+3


source


I cannot comment (I curse you SO) so I can add here that this solution DOESN'T WORK on 16.04. While on MacOS I was able to successfully filter an Apple EPP file containing many control characters A and ^ B, on Linux this does not work.

On macOS these templates worked:
^ #
. \ X0114344 [14] \ 01.
... \ X01143478 \ x01.



on Ubuntu no matter what you write char \ x01 or \ 01, strings are not matched against 2nd and 3rd strings. I don’t know the difference. Homebrew installed by grep and gnu grep should be identical.

0


source







All Articles