This is a useful Python one-liner for viewing characters that are usually hidden in text files;
- Carriage returns (shown as \r)
- Line feeds (shown as \n)
- Tabs (shown as \t)
python -c "f = open('filename.txt', 'r'); f.seek(0); file = f.readlines(); print file"
Example output:
['Carriage return and line feed: \r\n', 'Line feed: \n', 'Tab: \t\n']
I recently used this script when trying to work out why a shell script was not executing correctly on a Debian machine — the reason was some carriage returns inserted by a Windows-based editor.