[SOLVED] How to use Data of one file in another file???
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have two file file1.txt file2.txt,both file have content like following
file1.txt
Voltage and current behavior for diodes.
v1 2 3 dc 5v
Voltage and current behavior for transistor
v2 4 5 dc 6v
Voltage and current behavior for FET
v3 6 7 dc 2v
M.Tech(VLSI) in NIT jaipur
Simulation for V-I behaviour
file2.txt
2
3
4
the number in last coloumn of file1.txt should be replaced by number in file2.txt as follows,changes should be happened in line containg vn,n is integer e.g:1,2,3.........8....99...n.Result.txt file should look like as result.txt
result.txt
Voltage and current behavior for diodes.
v1 2 3 dc 2v<-----2 is coming from file2.txt
Voltage and current behavior for transistor
v2 4 5 dc 3v<-----3 is coming from file2.txt
Voltage and current behavior for FET
v3 6 7 dc 4v<-----4 is coming from file2.txt
M.Tech(VLSI) in NIT jaipur
Simulation for V-I behaviour
I have two file file1.txt file2.txt,both file have content like following
file1.txt
Voltage and current behavior for diodes.
v1 2 3 dc 5v
Voltage and current behavior for transistor
v2 4 5 dc 6v
Voltage and current behavior for FET
v3 6 7 dc 2v
M.Tech(VLSI) in NIT jaipur
Simulation for V-I behaviour
file2.txt
2
3
4
the number in last coloumn of file1.txt should be replaced by number in file2.txt as follows,changes should be happened in line containg vn,n is integer e.g:1,2,3.........8....99...n.Result.txt file should look like as result.txt
result.txt
Voltage and current behavior for diodes.
v1 2 3 dc 2v<-----2 is coming from file2.txt
Voltage and current behavior for transistor
v2 4 5 dc 3v<-----3 is coming from file2.txt
Voltage and current behavior for FET
v3 6 7 dc 4v<-----4 is coming from file2.txt
M.Tech(VLSI) in NIT jaipur
Simulation for V-I behaviour
Thanks in advance
Thanks and Regards
The answer to your question: through a program.
Which programming languages do you know and what code have you written so far ?
Hi Sergei I know C/C++ and Shell scripting but i am just a beginner like.i want to do my work in Shell script.
I wrote this
awk '{getline s < "file2.txt"; $NF=s"v"}1' file1.txt
but it is not working for me...Can please help me in correcting it or give me another solution for my problem in shell script or using AWK.I will be very thankful to you.
Hi Sergei I know C/C++ and Shell scripting but i am just a beginner like.i want to do my work in Shell script.
I wrote this
awk '{getline s < "file2.txt"; $NF=s"v"}1' file1.txt
but it is not working for me...Can please help me in correcting it or give me another solution for my problem in shell script or using AWK.I will be very thankful to you.
First describe in English how you would do this using your eyes, fingers and using as work media pieces of paper.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.