The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
problem in awk command viveksnv Shell Programming and Scripting 3 03-03-2008 01:59 AM
problem with tr command ravi raj kumar UNIX for Advanced & Expert Users 2 07-02-2007 03:41 AM
problem with dd command or maybe AFS problem Anta Shell Programming and Scripting 0 08-25-2006 07:10 AM
ls command problem buckhtr77 SUN Solaris 2 12-06-2005 01:16 PM
Problem while using Sed command gopskrish UNIX for Dummies Questions & Answers 2 06-27-2005 08:26 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-12-2008
Registered User
 

Join Date: Jan 2008
Posts: 10
Problem with tr command a-z 0-9

Hi experts,

I am getting a strange result when using the tr command.
I am using tr to change file names extensions created by split command ( from aa, ab, ac etc to 00, 01, 02 etc). If I run the script from command prompt I get the expected results but when I do it thru a cron tab and invoked from a perl scriipt i get strange results. For example ab gets converted to 08 but aa gets converted to 00.

+ old_ext=ae
+ print Old Extension ae
Old Extension ae
+ + tr a-z 0-9
+ echo ae
new_ext=0e
+ print New Extension 0e
New Extension 0e

for ab new_ext is coming as 08 from there onwards it is 0c, 0d,0e like that.


Here is the relevant portion of the code.
for i in `ls ${base_file_name}.a*`
old_ext=${i##*.}
print "Old Extension " $old_ext
new_ext=`echo $old_ext | tr 'a-z' '0-9'`
print "New Extension " $new_ext
done

any help would be highly appreciated as I spent many hours on this. I tried severl approaches like putting eval in front of echo but couldn't get this working.
Reply With Quote
Forum Sponsor
  #2  
Old 04-12-2008
Registered User
 

Join Date: Jan 2008
Posts: 10
tr a-z

I could solve the problem now. Instead of using 'a-z' I used 'abcdefghijk..'

That's all.
I am using aix and shell is ksh
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:20 AM.


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

Content Relevant URLs by vBSEO 3.2.0