Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2007

    Unanswered: how can i access value outside awk and how can i split string 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,,, in the directory.

    I am reading the file name and i am getting myinfo/yourinfo/supplierinfo/ 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.

    source ~/.login
    pruneclass="$(find myinfo/yourinfo/supplierinfo -name "**")"

    echo "$pruneclass"| awk '{
    z=split($0,flds," ")
    p2 = length(progcompile)
    progexe=substr(exetemp,0,length(exetemp)-5) # Please dont worry about the above code
    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.....

    source ~/.login
    pruneclass="$(find myinfo/yourinfo/supplierinfo -name "**")"
    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/ 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.

  2. #2
    Join Date
    Jun 2003
    Toronto, Canada
    Provided Answers: 1
    Check the basename command.
    "It does not work" is not a valid problem statement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts