Bat: How to Show Hidden Characters

Updated

Learn how to show hidden characters in a file using bat

Bat: How to Show Hidden Characters

Before we start, make sure you have bat installed on your computer and the text file you want to inspect ready in a folder. If you don't have bat yet, run this command:

brew install bat

First, open your terminal and navigate to the folder that has your file. To show the hidden characters, run this command:

bat -A input.txt

Just remember to replace input.txt with your actual filename. The -A flag stands for show all: every space becomes a dot, every tab becomes an arrow, and the line endings are shown too. A ␍␊ at the end of a line means the file uses Windows line endings, and dots at the end of a line are trailing spaces.

If you prefer the classic notation, add --nonprintable-notation=caret. The line endings then show up as ^M^J:

bat -A --nonprintable-notation=caret input.txt

You can also use --tabs with a number to change how wide the tab arrows are, for example --tabs=8.

undefined

One closing tip: you can pipe the output of any command into bat to check it for hidden characters, for example printf 'hello\tworld\r\n' | bat -A.