Sed is a very powerful tool when used correctly but can also be a source of frusteration at times.  One problem with it shows up when you are trying to identify and replace non-printable characters.  Luckily sed has a nice command line switch that will help you debug certain problems with sed.

When you just use cat to display a file, you’ll see it as you are normally used to but this isn’t how sed sees files.

cat hello.c

When you use the -n ‘l’, you’ll see the file how sed sees it.  (It’s a lower case “L” in the single quotes)

sed -n ‘l’ hello.c

Now you can see the new line characters at the end of the lines and the tabs that proceed some of the lines.



If you like the content on this site, please support it by using this link to order from Amazon. You know you were going to go there and buy stuff anyhow so why not help me pay the hosting bill.