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

  • Home
  • SEARCH
  • 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 7009315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:50:47+00:00 2026-05-27T21:50:47+00:00

I have a CSV file, formatted like this: 0001 @ word @ some information

  • 0

I have a CSV file, formatted like this:

0001 @ word @ some information @ other information @

The last column is left empty. I want to tag each line and put the tags in the last column.

I also have a directory, filled with plain text files containing nothing more than lists of words (1 per line). The filename of each list is identical to the tag I want to apply.

Lists/
Lists/fruit1
Lists/fruit2
Lists/vegetables1
Lists/vegetables2

How can I add the name of the every file which contains an exact match for the word in column 2 of the CSV to the end of the CSV? For e.g.:

A line in the CSV is like this, and the word “banana” appears in both of the lists in fruit1 and fruit2.

0004 @ banana @ some information @ other information @

The line above would have those two file names added to the last column of the CSV:

0004 @ banana @ some information @ other information @ fruit1 fruit2
  • 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-27T21:50:48+00:00Added an answer on May 27, 2026 at 9:50 pm

    You can do this using a loop to read each line. Extract the second field using cut, and then use grep to find the files containing this field. Then echo out your results.

    This is shown below:

    while read line
    do
        word=$(cut -d@ -f2 <<< "$line")
        results=( $(grep -l $word Lists/*) )
        echo "$line ${results[@]##*/}"
    done < input.txt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CSV file formatted like this: id @ word @ information @
I have a CSV file formatted just like this: name,color,tasty,qty apple,red,true,3 orange,orange,false,4 pear,greenish-yellowish,true,1 As
I have a CSV file that is formatted like: 0.0023709,8.5752e-007,4.847e-008 and I would like
I have a csv file which looks like this $lines[0] = text, with commas,
I have csv file with a line that looks something like this: ,,,,,,,,,, That's
I have a dictionary file formatted like this: A B [C] D Where a
I have a mal-formatted .csv file which is caused by some extra \n .
I have csv file that looks like this: artist,year,id,video_name,new_video_id,file_root_name,video_type ,,,,,, Clay Aiken,1,clay_aiken,Sorry Seems To
I have a CSV file that has only 1 column, but has close to
I have CSV file with sample data in this form : 220 30 255

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.