![]() |
program to merge 2 txt-files needed
I would need a simple program/script that can merge 2 txt-files into one. The way it should be done is that the first line from txt1.txt should be written into txt3.txt, then the first line from txt2.txt should be written at the end of the first line in txt3.txt, then the second line from txt1.txt and second line of txt2.txt should appear on line 2 in txt3.txt etc.
so when viewing txt3.txt it would look just like if i have created 2 tables on a webpage listing txt1.txt in the first one and txt2.txt in the second. Am i making any sense? if so, please help me out if anyone have something to do this, Thanks! |
should be simple with a few unix commands, i forget what they are though ;(
|
unix is simple. but you have to be a genius to understand its simplicity.
|
I will be more than happy for the time being if i just know how to merge a couple of files in the way described :)
|
ok, i remember now...
cat file1 file2 > file3 from a unix command line |
well heres a simple little php script that would do it....
Echo it to the screen then just save as .TXT PHP Code:
|
for i in $(ls file*)
do cat $i >> nameofnewfile done <enter> then the compiled file will be nameofnewfile |
pornJester: nah, that will only add the files after eachother..
MonkeyMan: great! thx! |
Nat please recopy the code or replace $START with the number 0
I forgot to do that. |
Quote:
|
MonkeyMan: em, help? :)
Parse error: parse error in /home/html/index.php on line 5 |
Quote:
|
Quote:
imadaddy.txt imadaddy2.txt imadaddy3.txt then do im* |
im*? what command are you reffering to?
|
for i in $(ls im*)
do cat $i >> nameofnewfile done this will combine all files that start with im into the 'nameofnewfile' |
Quote:
ooops on this line add the ; $length = 1000; and make shre you replace "(APPROX FILE LENGTH)" with a number you should have PHP Code:
|
yes, but it will just add txt2.txt to the end of txt1.txt, but i want them to be added on the same line, line for line... reread my first post for a better explanation...
|
Great! got it working...
thanks! |
All times are GMT -7. The time now is 07:12 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123