Frustrating error special character <96>


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Frustrating error special character <96>
# 1  
Old 08-26-2011
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...

Code:
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?
# 2  
Old 08-26-2011
Here is one way of doing it:
Code:
mCnt=$(echo ${REQUEST_TYPE} | egrep -c "New Request.*Id access")
if [[ "${mCnt}" = "1" ]]; then
  echo "Found"
else
  echo "did not find"
fi

This User Gave Thanks to Shell_Life For This Post:
# 3  
Old 08-26-2011
See hex number of this char with xxd YOURFILE, and use $'...' string literal like this:
Code:
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).
This User Gave Thanks to yazu For This Post:
# 4  
Old 08-26-2011
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Special character $$

Hi, on ksh What does the following do? grep -v "toolbox" $home_oracle/.profile >$home_oracle/.profile.$$ Thanks. Please use CODE tags as required by forum rules! (3 Replies)
Discussion started by: big123456
3 Replies

2. Shell Programming and Scripting

Escape special character

Hi, How to use * in call to pl/sql block from shell script? The line "select * from" is causing all files and directiores to show up in email notification but if I give all column names then it works, Please let me know how to use '*' instead of giving all column names, in other wirds how to... (2 Replies)
Discussion started by: sandy162
2 Replies

3. Shell Programming and Scripting

Vi special character

When editing a file, vi displays a special character as ^L. Can you tell me the escaped character to be used in awk? And can that escaped character be used in a regexp in both sed and awk? (7 Replies)
Discussion started by: dmesserly
7 Replies

4. Shell Programming and Scripting

Deleteing one character after an special character

I have below line in a unix file, I want to delete one character after "Â". 20091020.Non-Agency CMO Daily Trade Recap Â~V Hybrids The result should be : 20091020.Non-Agency CMO Daily Trade Recap  Hybrids i dont want to use "~V" anywhere in the sed command or any other command, just remove... (1 Reply)
Discussion started by: mohsin.quazi
1 Replies

5. Shell Programming and Scripting

Special character \

Hi, In the shell script, i need to remove the special charater "\" with "\\". For example, i need to replace "D:\FXT\ABC.TXT" with "D:\\FXT\\ABC.TXT". However, when trying to do something like , i get the below error :- -->echo "D:\FXT\ABC.TXT" | sed -e 's#\#\\#g' sed: 0602-404 Function... (7 Replies)
Discussion started by: amit_arora
7 Replies

6. UNIX for Advanced & Expert Users

grep in special character

All, I am trying to grep "-----" from a test when i use this i am getting the below error. What is the reason for this ?????... How can i over come this ##) echo "----------------- test_sys_job -----------------" | grep "-----------------" grep: illegal option -- - grep: illegal... (6 Replies)
Discussion started by: arunkumar_mca
6 Replies

7. Shell Programming and Scripting

special character

Hi, I am trying to unload file from a database. Which contains few lines with the character below. Rest of the data was unloaded appropriately. a) What does this below character means? b) How can i remove it, I already have sed '/^$/d' c) Will this effect the file by any means... (4 Replies)
Discussion started by: tostay2003
4 Replies

8. Shell Programming and Scripting

convert special character like £

i had a shell script writing a xml file. I need to use "& # 163;" instead of "£", and replace others characters like: > to &gt; , and so on.. Anyone know how to convert the character automatically? my script as below: do # GET FEED REC SQL2="SELECT A.*, B.subject FROM feed_details A,... (1 Reply)
Discussion started by: cynnie
1 Replies

9. UNIX for Dummies Questions & Answers

Special character in my file

I have a special character in my file. It displays as a '#' sign but when I do this command I do not find the line. fgrep 'G#ant' file1 I want to replace the special character with another value but I need to know what character it really is. Any ideas on how to replace this '#' value with... (3 Replies)
Discussion started by: Ryan2786
3 Replies

10. Programming

special character ?

hey there im a bit stuck on executing commands that include the special character '?'. can someone recommend a way on how i would be able to execute it?? i thought the glob function could be useful (still mite be) but upon entering the command 'ls pars?' it listed all the files in the... (1 Reply)
Discussion started by: mile1982
1 Replies
Login or Register to Ask a Question