Frustrating error special character <96>

Hiya Folks,
Wondering if anybody has ran into this before, it's driving me nuts! Searching on this in the forums didn't turn up anything that was any help.

My script is going through a csv file I have, running ksh under Cygwin. The code I have is...

REQUEST_TYPE=$(grep REQ $FILES | awk -F, '{print $3}')
 
<snip>
 
if [[ $REQUEST_TYPE = "New Request - Id access" ]]; then

The only problem is... it's actually in the file as
New Request <96> Id access

And shows up with an echo as
New Request Id access

Anybody have any idea on how to make that if statement work?

Here is one way of doing it:

mCnt=$(echo ${REQUEST_TYPE} | egrep -c "New Request.*Id access")
if [[ "${mCnt}" = "1" ]]; then
  echo "Found"
else
  echo "did not find"
fi
1 Like

See hex number of this char with xxd YOURFILE, and use $'...' string literal like this:

if [[ $REQUEST_TYPE = "New Request \xNN Id access" ]]; then

But it's better to learn encoding of your file ("file" command may help) and convert to utf-8 with iconv (for cygwin 1.7x only).

1 Like

Thanks guys!! I unfortunately do not have control over the installation of components into Cygwin but I was able to use the solution provided by Shell Life. Thanks so much! This has been bothering me all morning.