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 8319635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:23:12+00:00 2026-06-08T22:23:12+00:00

I need to do something similar to this post (but with a twist). That

  • 0

I need to do something similar to this post (but with a twist). That is why I am asking.

unix shell: replace by dictionary

I have a dictionary(dict.txt). It is space separated and it reads like this:

V7 Momentum

B6 Quanta

….

(the first column is key and the second column is value, in a sense)

I have a user file (user.txt), it contains the occurrences of the keys (V7, B6 etc). The twist is that keys are not in its own column (so the method in the above post does not apply).

The user file (user.txt) can be view as a stream of characters. I just want to replace all occurrences of the keys (e.g., V7), regardless they are bounded by space or bounded by other character by the value (Momentum) looked up from the dictionary.

For example:

“We have V7 as input” –> should change to –> “We have Momentum as input”

“We have somethingV7_as input” –>should change to –> “We have somethingMomentum_as input”

  • 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-06-08T22:23:16+00:00Added an answer on June 8, 2026 at 10:23 pm

    Usage: awk -f foo.awk dict.dat user.dat
    http://www.gnu.org/software/gawk/manual/html_node/String-Functions.html
    http://www.gnu.org/software/gawk/manual/html_node/Arrays.html

    NR == FNR {
      rep[$1] = $2
      next
    } 
    
    {
      for (key in rep)
        gsub(key, rep[key])
      print
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In addition to this quite old post , I need something that will use
This post is similar to: this I have a console app that expects both
I need to build a Windows control that displays KPI indicators. Something similar to
I need something like this http://jonraasch.com/blog/a-simple-jquery-slideshow but w/o the absolute positioning. Is it possible?
I asked a similar question before ( integer-vs-char-for-db-record-property ) but stumbled upon something that
I want something similar to Mysql's sorting of data, but in jquery. I have
I have a process that I need to follow, I hope this makes sense.
I have a very similar question to this SO post: TFS Build 2010 -
Is there a URL encoding function in XSLT version 1? I need something similar
I need something simple like date , but in seconds since 1970 instead of

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.