convert special character like £


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting convert special character like £
# 1  
Old 08-08-2007
Data 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 > , 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, feed_category B where A.status=0 and A.feedCategoryId=B.id limit 1"
#FEED="$(/usr/bin/mysql -N -u${DB_USER} -p${DB_PWD} -h${DB_HOST} ${DB_NAME} -e "${SQL2}")"
FEED="$(/usr/bin/mysql -N -u${DB_USER} -p${DB_PWD} ${DB_NAME} -e "${SQL2}")"
arrayDB=($FEED)

echo " <item>"
echo " <guid isPermaLink="false">SMS${arrayDB[$dbId]}-${DB_CUR_DATE}</guid>"
echo " <pubDate>${arrayDB[$dbPubishDate]}</pubDate>"
echo " <dc:subject>${arrayDB[$dbSubject]}</dc:subject>"
echo " <dc:description>SMS</dc:description>"
echo " <dc:type>Text</dc:type>"
echo " <dc:format>text/plain</dc:format>"
echo " <description>${arrayDB[$dbDescription]}</description>"
echo " </item>"

# UPDATE STATUS TO 1 (DONE)
SQL3="UPDATE feed_details SET status=1 WHERE id='${arrayDB[dbId]}' limit 1"
done


I am trying to convert the value from DB to xml character set, £--> "& # 163;"
Anyone can help???
# 2  
Old 08-08-2007
Many solutions , u can transfrom via dml using the function replace.
Code:
  1* select replace('example£1','£','& # 163;') from dual
Pulse cualquier tecla para continuar ...

REPLACE('EXAMPLE
----------------
example& # 163;1

Or you can modify the variable:
Code:
FEED="example£1"
FEED=$(echo ${FEED}|sed -e "s/£/& # 163;/g")

Or if you have perl , and wanna change a source data.
Code:
perl -pi -e "s/£/& # 163;/g" file_2_change

Or ...
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

How to convert special characters?

Hi All, I have some text including Turkish characters and the 3rd party application that reads my file does not supporting this character set (at least, I have no control on it). So, I used below conversion for maximum character support but still have problems with "İ" and "Ş". Application... (5 Replies)
Discussion started by: mrcrowley
5 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. OS X (Apple)

vi and special character removal

To the group, when I copy text from a web page that has the below java code , and then do the set list command in the vi editor, I see the $ symbol at the end of each line. I have searched the internet looking for a way to remove this from the file since it will not compile without errors..Please... (6 Replies)
Discussion started by: smartino
6 Replies

5. Shell Programming and Scripting

Convert special charachter ^C to new line

Hi, I have a file, which contains ^C or ^A characters from mainfrme system, it's dec 192 or octal 300 hex C0. I want to replace this character with new line. I used commands, but it didn't worked. tr '\o300' '\n' <t >t2 #or tr '\xC0' '\n' <t > t2 Can somebody help me to do... (2 Replies)
Discussion started by: vnag97
2 Replies

6. Shell Programming and Scripting

How to check for special character in a value

Hi, I have a variable and to it always alphanumeric value will be assigned. If the value has any special characters in it then in the if statement it should exit like below if (value has any speacial character) then exit else .... fi can any one suggest how to acheive this? (4 Replies)
Discussion started by: lavnayas
4 Replies

7. 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

8. 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

9. 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

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