![]() |
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 |
| split variable values into array | finalight | Shell Programming and Scripting | 4 | 05-21-2008 03:21 AM |
| split varibles and store fields into shell varible array | gratus | Shell Programming and Scripting | 3 | 10-11-2007 02:50 PM |
| [KSH] Split string into array | piooooter | Shell Programming and Scripting | 3 | 09-01-2007 12:22 PM |
| How to get array to not split at spaces? | jjinno | Shell Programming and Scripting | 1 | 07-20-2007 12:06 AM |
| split to array in perl | jaganadh | Shell Programming and Scripting | 3 | 07-06-2007 05:29 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Access value outside awk or split value of array
Hello I am new to Unix. Please help me out.
My Scenario: I am first collecting all the file names present in the directory with structure myinfo/yourinfo/supplierinfo I have four files with the names myCollector.java, yourCollector.java, someCollector.java, everyCollector.java. in the directory. I am reading the file name and i am getting myinfo/yourinfo/supplierinfo/myCollector.java. and the such string for other files. I am spliting it to get only substring "myCollector" from the above string which is stored in variable progexe. How can i access this variable outside awk so that i can run that java class. #!/bin/bash source ~/.login progexearr="" pruneclass="" pruneclass="$(find myinfo/yourinfo/supplierinfo -name "*llector.java*")" echo "$pruneclass"| awk '{ z=split($0,flds," ") for(i=1;i<=z;i++) progcompile=flds[i] p2 = length(progcompile) exetemp=substr(progcompile,41,p2) progexe=substr(exetemp,0,length(exetemp)-5) # Please dont worry about the above code progexearr[i]=progexe print progexe # i am getting myCollector, yourCollector,someCollector and everyCollector. How can i access the value of variable and array outside awk. print progexearr[i] }' #echo $progexe # Not able to get value of progexe or array progexearr here #java -classpath $CLASSPATH:. $progexe OR i have used another approach which is..... #!/bin/bash source ~/.login pruneclass="" pruneclass="$(find myinfo/yourinfo/supplierinfo -name "*llector.java*")" st=(echo "$pruneclass") for (( j = 0 ; j <= ${#st[*]} ; j++ )) { #echo ${st[*]} echo "${st[$j]}" #echo ${st[j]} javac ${st[$j]} # Here the string is myinfo/yourinfo/everyinfo/myCollector.java which is compiling absolutely fine #java -classpath $CLASSPATH:. ${st[$j]} # But here i want only substring "myCollector" in order to execute it. How do i split the string values of array to get the substring "myCollector". } Any help would be really appreciated. I am trying it for 3 days and not yet successful. Thanks in advance. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|