troubleshooting Question

Awk Sub() function with arary indexs

Avatar of Phonebuff
PhonebuffFlag for United States of America asked on
SoftwareLinux OS Dev
8 Comments1 Solution681 ViewsLast Modified:
Good Evening,

    Need some help with a basic awk script..

    I have created to arrays and wish to replace the value in element n of array 1 with the Value of Element n in array 2.

Awk '
    BEGIN {

               split("value1 value2 valuen", array_1, " ")
               split("newval1 newval2 newvaln", array_2, " ")
               }

                    for (x=1, x<=15, x++) {
                              if (array_1[x] == $6) break;
                     }
                    sub(/array_1[x]/, array_2[x] );  print
 '

     But the output string is not altered.
           
      ============
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros