The UNIX and Linux Forums  

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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Weird Ascii characters in file names yamsin789 Shell Programming and Scripting 2 10-07-2007 07:27 AM
Multibyte characters to ASCII jerardfjay Shell Programming and Scripting 8 11-17-2005 10:45 PM
Hex characters of ascii file budrito HP-UX 2 08-10-2005 07:26 PM
stupid question about ascii characters jalburger High Level Programming 2 09-28-2004 12:56 PM
Replace string and delete extra characters slaubhan Shell Programming and Scripting 2 08-28-2003 02:49 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-03-2005
Registered User
 

Join Date: Mar 2005
Posts: 2
Replace characters in a string using their ascii value

Hi All,

In the HP Unix that i'm using when i initialise a string as Stalled="'30¬G'"
Stalled=$Stalled" '30¬C'", it is taking the character ¬ as a comma. I need to grep for 30¬G 30¬C in a file and take its count. But since this character ¬ is not being understood, the count returns a zero.
The ascii value of the character ¬ is 188.
I thought of replacing all occurrences of comma using something like
chr(188). But i dont know how to.
Could some one help me or give me some other idea to go about this. I need to do this urgently :-(
Thanks in advance...
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-03-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 2,999
Quote:
Originally Posted by roops
Hi All,

In the HP Unix that i'm using when i initialise a string as Stalled="'30¬G'"
Stalled=$Stalled" '30¬C'", it is taking the character ¬ as a comma. I need to grep for 30¬G 30¬C in a file and take its count. But since this character ¬ is not being understood, the count returns a zero.
The ascii value of the character ¬ is 188.
I thought of replacing all occurrences of comma using something like
chr(188). But i dont know how to.
Could some one help me or give me some other idea to go about this. I need to do this urgently :-(
Thanks in advance...
tr '\188' ',' < file

Last edited by vgersh99; 03-03-2005 at 06:05 AM.
Reply With Quote
  #3 (permalink)  
Old 03-03-2005
Registered User
 

Join Date: Mar 2005
Posts: 2
Hi vgersh99

Thank u very much for the pointer u gave. But i cracked this problem using grep itself. I said in 30¬G, let the 3rd character(each record in the file starts with 30¬G or 30¬C ) be anything other than zero (since in the file it is alwz ¬ and never zero.) and the fourth character shud be [GC]. From the grep, i got the count..

Thanks anyways coz i learnt what "tr" command is all about. I'm new to unix and my work revolves around unix. So i'm learning Unix while i'm working on live problems. :-)
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:42 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0