LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-15-2022, 07:12 AM   #1
vanKey
LQ Newbie
 
Registered: Jun 2022
Posts: 17

Rep: Reputation: 0
bash awk: comparing two files and possibly overwrite context from one file to the other


Hello all,

I have another slightly different, but as I think far more complex question as before.
I again have two files file_a.txt and file_b.txt.


content of file_a.txt
Code:
1000     0          0          0          1          2          3
2000     0          0          0          4          5          6
3000     0          0          0          7          8          9
content of file_b.txt
Code:
1          101       
2          102
3          103
4          104
5          105
6          106
7          107
8          108
9          109

Now I want to overwrite the entries of columns 4,5,6 of file_a.txt with the values given in file_b.txt and write it to file_c.txt. Afterwards file_c.txt it should look like.

content of file_c.txt
Code:
1000     0          0          0          101        102        103
2000     0          0          0          104        105        106
3000     0          0          0          107        108        109
Can anyone help me out here? Would be grate.

Kind regards
vanKey
 
Old 06-15-2022, 07:13 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,145

Rep: Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124
Duplicate - reported.
 
Old 06-15-2022, 07:26 AM   #3
vanKey
LQ Newbie
 
Registered: Jun 2022
Posts: 17

Original Poster
Rep: Reputation: 0
No sry, it is actually not a duplicate. I'm sorry.

Kind regards
 
Old 06-15-2022, 07:32 AM   #4
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,616

Rep: Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555

This is clearly a later part of the same homework you asked about here:

https://www.linuxquestions.org/questions/programming-9/bash-awk-comparing-two-files-and-possibly-adding-context-from-one-file-to-the-other-4175713430

(And had you made the effort understood how to solve that task, you would be able to easily solve this one yourself.)


Last edited by boughtonp; 06-15-2022 at 07:33 AM.
 
Old 06-15-2022, 07:55 AM   #5
vanKey
LQ Newbie
 
Registered: Jun 2022
Posts: 17

Original Poster
Rep: Reputation: 0
Ok, if you think so I can't help you.
 
Old 06-15-2022, 07:59 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,976

Rep: Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337
Quote:
Originally Posted by vanKey View Post
Ok, if you think so I can't help you.
I don't think that's a good approach. You need help, you don’t have to help anyone.
 
Old 06-15-2022, 08:20 AM   #7
vanKey
LQ Newbie
 
Registered: Jun 2022
Posts: 17

Original Poster
Rep: Reputation: 0
I don't know if that is true. I postet the correct solution to the problem. What else do you expect?
 
Old 06-15-2022, 08:22 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,976

Rep: Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337
Quote:
Originally Posted by vanKey View Post
I don't know if that is true. I postet the correct solution to the problem. What else do you expect?
in that case just mark the thread solved.
 
Old 06-15-2022, 08:34 AM   #9
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,333
Blog Entries: 3

Rep: Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730
Quote:
Originally Posted by vanKey View Post
I postet the correct solution to the problem.
Not really. There are a lot of problems with the copypasta, both in general and in specific to your stated homework.

Please work through your copypasta and explain the components, you'll need to know what they are and what they do in order to get through the next steps.
 
Old 06-15-2022, 07:00 PM   #10
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
This question is clearly related to this one, but slightly different. As this has been discussed in thread already let's leave both threads open for the time being. In future please post follow-on questions (i.e. variations on a theme) in the original thread as that makes it easier for others to follow and makes the discussion more accessible and useful to future visitors who may land here.

Please review the Site FAQ for guidance in asking well formed questions and proper forum usage. Especially visit the link from that page, How to Ask Questions the Smart Way for discussion of things to consider when asking others for help.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash awk: comparing two files and possibly adding context from one file to the other vanKey Programming 8 06-15-2022 07:21 AM
[SOLVED] Comparing two files and looking for the same line based on field - awk sopier Programming 8 12-26-2011 02:53 PM
AWK Comparing two files elonden Programming 2 12-09-2011 09:23 AM
[SOLVED] awk comparing first columns of two files anapaula Programming 1 11-17-2011 03:50 PM
[SOLVED] Comparing two fields in two files using Awk. Tauro Linux - Newbie 16 07-21-2011 12:47 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration