ISO27001:2013
Certified Supplier

FIND OUT MORE

We're an ISO27001:2013 Certified Supplier

blog-post-featured-image

I was asked the other day to help someone who was running a bash script where part of the output was command not found.

That’s not an especially unusual error, often stemming from users perhaps not understanding the role of the PATH environment variable. In this case, though, the user had reduced the script to something very simple that was showing the error:

The Error

Running it:

Running it with -x switch:

Checking that bash finds the date command shows no problem:

Even putting the full path of the command in didn’t fix the issue.

The Solution

After a lot of testing and some strange results, I finally dumped the script with od:

Aha! Those octal 302 240 codes look odd! They are the Unicode non-breaking space, but bash doesn’t understand them. Inside vim, you can highlight non-ASCII characters with:

That showed the two non-breaking spaces, and makes it easier to remove them.

It turned out that the user had copied and pasted some code from a website, and that was how the Unicode characters became embedded in his script. Once removed, the script worked as intended.

Could this Linux Tip be improved? Let us know in the comments below.

Leave a Reply

Your email address will not be published. Required fields are marked *