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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Easy sed question? earnstaf UNIX for Dummies Questions & Answers 6 06-19-2007 11:02 AM
Hopefully an Easy Question lesstjm Shell Programming and Scripting 6 05-31-2007 09:23 AM
Easy AWK question rdudejr Shell Programming and Scripting 9 07-15-2006 01:09 AM
Another easy question catbad UNIX for Dummies Questions & Answers 3 04-04-2003 11:06 AM
Easy question Bab00shka UNIX for Dummies Questions & Answers 4 07-02-2002 07:57 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 07-01-2002
champion champion is offline
Registered User
  
 

Join Date: Jul 2002
Posts: 64
bad substitution problem (easy question)

hi,

what i want to do is to convert all the txt file under my directory to the properties file using the native2ascii command.

however, when i run my script, i got bad substitution error. what's wrong with my script ? pls help. thanks

#!/bin/sh

curDIR=`pwd`
oldExt='txt'
newExt='properties'

for i in ${curDIR}/* ; do
/opt/FJSVawjbk/jdk13/bin/native2ascii $i ${i%$oldExt}$newExt
done
  #2 (permalink)  
Old 07-01-2002
peter.herlihy peter.herlihy is offline
Registered User
  
 

Join Date: Nov 2001
Location: New Zealand
Posts: 333
You're not really using the 'txt' entension....

for i in ${curDIR}/*${oldExt} ; do

But that shouldn't cause you problems..... I have tried this

curDIR=`pwd`
oldExt='properties'
newExt='herlihy'

for i in ${curDIR}/*${oldExt} ; do
/usr/develop/j2sdk1_3_0_02/bin/sparc/native_threads/native2ascii $i ${i%$oldExt}$newExt
done

And it works.....can you replace your native2ascii command and try a copy command instead to see it that accepts...make sure that you have some files with the oldExt - otherwise there is nothing for the script to do.
  #3 (permalink)  
Old 07-01-2002
champion champion is offline
Registered User
  
 

Join Date: Jul 2002
Posts: 64
hi,

after my investigation, the error comes from the ${i%$oldExt}

let's say my $i is /export/home/pbn/Japanese/AdmissionControl.txt

and i set oldExt='txt'

so why ${i%$oldExt} will give me bad substitution error?

pls help

thanks
  #4 (permalink)  
Old 07-01-2002
peter.herlihy peter.herlihy is offline
Registered User
  
 

Join Date: Nov 2001
Location: New Zealand
Posts: 333
${i%$oldExt} is only part of that substitution....

How are you sure that's the problem...??

try -
echo ${i%$oldExt}$newExt
echo ${i%$oldExt}
in your script. What do you get?
  #5 (permalink)  
Old 07-01-2002
champion champion is offline
Registered User
  
 

Join Date: Jul 2002
Posts: 64
hi, thank u for ur patient and help.

now this is my source code:
#!/bin/sh

curDIR=`pwd`
oldExt='txt'
newExt='properties'

for i in ${curDIR}/*${oldExt}; do
echo $i
echo ${i%$oldExt}$newExt
echo ${i%$oldExt}

# /opt/FJSVawjbk/jdk13/bin/native2ascii $i ${i%$oldExt}$newExt
done


this is my directory and runtime result:

pbn@hercules:[260] >ls
AdmissionControl.txt DeviceList.txt DiffServPHB.txt MiscMessages.txt PolicyListView.txt UserManagement.txt
BandWidthControl.txt DeviceManagement.txt DiffservClass.txt NetworkView.txt Provisioning.txt native.sh*
pbn@hercules:[261] >native.sh
/export/home/pbn/Japanese/AdmissionControl.txt
native.sh: bad substitution
pbn@hercules:[262] >
  #6 (permalink)  
Old 07-01-2002
peter.herlihy peter.herlihy is offline
Registered User
  
 

Join Date: Nov 2001
Location: New Zealand
Posts: 333
Okay one more thing before I give up and suggest that it's somthing to do with the OS version you are using and get well in over my head....

Does

echo ${i%$oldExt}

Work? I.e just comment out the line that has the $newExt in it.
  #7 (permalink)  
Old 07-01-2002
champion champion is offline
Registered User
  
 

Join Date: Jul 2002
Posts: 64
same thing, same error.

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 12:30 AM.


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