Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7667465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:06:34+00:00 2026-05-31T15:06:34+00:00

I am trying to edit an array element as to convert a format of

  • 0

I am trying to edit an array element as to convert a format of #1:#2,#3,… so that #1 would show file name, and #2-#n show their full file names, and have a count of #2-#n.

< EDIT >

12:12,13 means:

For ${names} entry “12”, there exists entries in ${names} such that entries 12 and 13 are duplicates

< /EDIT >

Contents of ${merge}

key: 0 value: 12:12,13
key: 1 value: 18:18,19

Some contents of ${name} (just last part of ${path}

key: 12 value: j.smith
key: 13 value: j.smith
key: 18 value: test
key: 19 value: test

Some contents of ${path}

key: 12 value: ./testDir/first/j.smith
key: 13 value: ./testDir/j.smith
key: 18 value: ./testDir/second/test
key: 19 value: ./testDir/third/test

My attempt:

for ix in "${merge[@]}"
do
        # Remove "#:" from "#:#,#" string and pass #,# into awk
        echo ${ix} | sed s/[0-9]*:// | awk -v name="${name[*]}" '
        {
        FS=",";
        print "\File: ",$name," Number of Matches:",NF;
            for (ix=0; ix<NF; ix++)
            {
                print $ix,": ",$path[$ix];
            };
        print "END"; }'
done

This is what I’m getting

File:  12,13  Number of Matches: 1
12,13 :  12,13
END

File:  18,19  Number of Matches: 1
18,19 :  18,19
END

What I’m trying to get:

File: j.smith

Number of Matches: 2

./testDir/first/j.smith

./testDir/j.smith

File: test

Number of Matches: 2

./testDir/second/test

./testDir/third/test

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:06:36+00:00Added an answer on May 31, 2026 at 3:06 pm
    merge=([0]="12:12,13" [1]="18:18,19")
    name=([12]="j.smith" [13]="j.smith" [18]="test" [19]="test")
    path=([12]="./testDir/first/j.smith" [13]="./testDir/j.smith" [18]="./testDir/second/test" [19]="./testDir/third/test")
    
    for ix in "${merge[@]}"
    do
        a=${ix%%:*}
        b=(`echo ${ix##*:} | sed 's/,/ /g'`)
        n=${name[a]}
        echo
        echo "File: $n"
        echo "Number of Matches: ${#b[@]}"
        for i in ${b[@]}
        do
            echo ${path[$i]}
        done
    done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to edit a record. I have the default route. When I
I have been trying to edit the jquery buttons in order to modify them
I have a problem trying to edit. I work with Areas for better management
I have a relatively big SSIS package which I'm trying to edit. I basically
I am trying to find the location of an element in the array. I
I have a child element of a div named bob that's class is '.divTitle'
I am reading a file that has 10,000 int values and then trying to
i am trying to create a select element with JS or even edit an
I'm just trying to shorten a line of code that assigns HTML::Element->as_trimmed_text from an
I am trying to edit this code so that instead of just inserting the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.