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 files with thousands of line, I am trying to combine these two files but i want to insert each line of one file to the another file after certain lines. I am using awk with the following command but it does not work.
Please give us an example of the input file contents, and the desired output format. Also, what do you mean specifically by "it doesn't work"? It's very hard to give specific advice without knowing what we're working with.
This is long file of the simulation trajectory. I want to put each different and consecutive line from file 2 to file 1 after specific lines e.g after every 50 lines.
Thanks for the reply i have two files traj_H2O2.xyz and t.xyz, I want to insert each line of file t.xyz in another file traj_H2O2.xyz using the following command with get line.
It just puts every line of other file (file2) with every line of first file (file1) but i want to put the each line of a file (file2) into another file (file1) after specific interval then another line of file (file2) to another file (file1) after same specific interval.
Thanks, I have a very large file. But i can give real input of my work below.
file 1
O -6.230600 3.314400 -12.287100
H -6.119800 3.047300 -11.368100
H -6.533100 4.204800 -12.096600
O 12.104800 2.198100 -15.244801
H 13.015100 2.087200 -15.000700
H 11.760301 2.773000 -14.558399
O 2.163200 14.690200 -12.447701
H 1.316700 14.269799 -12.596399
H 1.994400 15.476899 -13.053499
O 15.386072 6.185700 10.372772
H 14.869772 6.957000 10.262774
H -15.260300 6.326600 11.209572
O -0.915700 -6.342100 10.467173
H -0.108700 -6.814900 10.350771
H -1.477300 -6.455300 9.654371
O 6.318500 9.950600 2.828700
H 6.415500 8.971100 2.673700
H 7.237900 10.170699 2.589300
output
O -6.230600 3.314400 -12.287100
H -6.119800 3.047300 -11.368100
H -6.533100 4.204800 -12.096600 Q 0.4402 -0.49655 -0.19745
O 12.104800 2.198100 -15.244801
H 13.015100 2.087200 -15.000700
H 11.760301 2.773000 -14.558399 Q 0.4392 -0.4938 -0.1963
O 2.163200 14.690200 -12.447701
H 1.316700 14.269799 -12.596399
H 1.994400 15.476899 -13.053499 Q 0.43845 -0.4914 -0.19525
O 15.386072 6.185700 10.372772
H 14.869772 6.957000 10.262774
H -15.260300 6.326600 11.209572 Q 0.43775 -0.48955 -0.1947
O -0.915700 -6.342100 10.467173
H -0.108700 -6.814900 10.350771
H -1.477300 -6.455300 9.654371 Q 0.4373 -0.4882 -0.19495
O 6.318500 9.950600 2.828700
H 6.415500 8.971100 2.673700
H 7.237900 10.170699 2.589300 Q 0.43705 -0.48725 -0.1964
It shows that the both input file are different and each different line of file2 come after certain lines of file1. Its a short illustration but i have to put each different lines of file2 after specific interval of 3004 line of file 1.
I hope that this post would help you to understand my problem.
Regards
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.