The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need help to escape special characters in Korn shell script rogers42 UNIX for Dummies Questions & Answers 6 05-14-2009 07:23 AM
Sed-Special character replacement usshell Shell Programming and Scripting 3 05-22-2008 10:06 AM
bash script to check the first character in string ole111 Shell Programming and Scripting 2 03-19-2008 12:34 AM
Check for special characters in a script sumesh.abraham Shell Programming and Scripting 7 12-18-2006 09:15 AM
special character ? mile1982 High Level Programming 1 10-19-2004 08:15 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-24-2006
mradul_kaushik mradul_kaushik is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 3
Special Character Check in Shell script

Hi,

I'm currently working on a project that requires parsing xml file. One of the field in the xml is shown below (don't remember exactly):
<variable="ITEM">12345678</variable>
I coded my script keeping in mind that the value denoted in bold will always be a number. After getting just the number I have to fire a PL/SQL procedure from the script itself and get the data, and update the existing xml file with some new fields that i received by firing the procedure.
But now the requirements have changed and now the users wants a check for special characters on the item shown as bold.
eg: We refer the text in bold as Item Number. So if the following Item Number is found 1234%1234, in this case my script should remove only the % sign and put together the rest of the numbers and form one number.
Now the problem is that there are 36 such special characters on the keyboard.
I tried using ITEMNUMBER=echo $ITEMNUMBER|sed 's/%//g'
But this would work for only one scenario. If i follow this case, I have to write 36 such statements and that would inturn reduce the performance of the script.
PS: Keep in mind the following special charaters in unix 1. & - &amp;
2. < - &lt;
3. > - &gt;
4. " - &quot;
5. ' - '

Hoping for some help

Thanks in advance.

MK
  #2 (permalink)  
Old 03-24-2006
mph mph is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 58
mradul_kaushik,

Use something like this.
Code:
sed -e 's/[[:alpha:]]\|[[:punct:]]//g'
This will remove any alpha and punctuation char's.

Hope it helps,

MPH
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0