![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 |
|
||||
|
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. |
|
||||
|
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] > |
|
||||
|
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. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|