Unix 101 : Showing non-printing characters in text files (ex : DOS files)

A non-printing character is a character which won’t actually get directly printed (or displayed) but rather interpreted. Such non-printing characters are for example line-feed or tabulation. The interpretation of those characters can differ from one system to the next. For example the line-feed character is different on Unix or DOS.

If you need an easy way to confirm that a text file is DOS or UNIX formatted (they differ with respect to the end of line character(s) for example) or if you wish to display normally non-printing characters of a text file, you can use the -vET command line switches of the cat utility.

As explained in the man page :

  • -v : will use the ^ and M- notation for control and multibytes characters
  • -E : will make ends of lines visible
  • -T : will make tabulations visible

For example : Continue reading Unix 101 : Showing non-printing characters in text files (ex : DOS files)

Linux : Using loop devices (eg : mounting an ISO file)

If you downloaded an ISO file and you want to mount it into your filesystem, you can proceed as follows :
spaghetti% sudo losetup /dev/loop0 cdrom.iso
spaghetti% sudo mount /dev/loop0 /mnt
spaghetti% ls /mnt
Autorun.inf setup.exe setup.ico
spaghetti% sudo umount /mnt
spaghetti% sudo losetup -d /dev/loop0

This will use the feature known as “loop devices”, which lets you use a file as a device, and subsequently mount it as it would be one.

You can of course mount an ISO using loop devices, but there is more to it. You could for example mount a ciphered file containing an EXT2 filesystem.

Check out the man page for more details.