Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Parse 2 files line by line to 1
Name: t8mas Date: April 7, 2009 at 00:47:26 Pacific OS: Windows XP Subcategory: Batch
Comment:
Hi,
I have this problem that i want to parse each line of file 1 and 2 and then combine it side by side on a new file. say, file 3.
example.
if i have these lines from file 1: better beer and i have these lines from file 2: honey bees
i should have a file 3 with the following output lines:
Name: ghostdog Date: April 7, 2009 at 00:57:07 Pacific
Reply:
if you have vbscript, open each file and read the lines into arrays. then use a loop to display the 2 arrays, each time printing out the contents side by side. an alternative : If you can download coreutils ( see link in my sig), you can just do a paste
Name: Mechanix2Go Date: April 7, 2009 at 01:28:24 Pacific
Reply:
@echo off > newfile & setLocal EnableDelayedExpansion
set N= for /f "tokens=* delims=" %%a in (file1) do ( set /a N+=1 set o!N!=%%a )
set N= for /f "tokens=* delims=" %%a in (file2) do ( set /a N+=1 set t!N!=%%a )
for /L %%a in (1 1 !N!) do ( echo !o%%a! !t%%a! >> newfile )
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 3
Name: t8mas Date: April 7, 2009 at 03:07:12 Pacific
Reply:
wow! thanks M2. as expected from you, it works! I've read most of your codes here and thanks for replying. ghost, ill try that if i have a chance. unfortunately, all i can use is batch file/dos cmd prompt for now.thanks anyway.
Summary: hey again! thx for the help at my last post! want to ask if there is some way i can read a .txt file line by line ignoring lines beginning with "::" then writing the lines back into a file but without...
Summary: Hi, I need to compare 2 files using awk, file1 & file2 line by line. Field 5 in everyline of file1 should be compared in whole file2 & if match is found then print that line in file2 & then print next...
Summary: Koshare, I wrote a Awk / Bash script to do what you are wanting to do. There may be a easier way or more streamlined... but this script works. I developed and ran it on a Gentoo Linux box, so the ...