LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Concatenating two files (https://www.linuxquestions.org/questions/linux-newbie-8/concatenating-two-files-4175427788/)

ingridsvensson 09-18-2012 04:41 AM

Concatenating two files
 
Aloha

I am new to the linux environment and would like to pose this question:

File1.txt
---------
01659942.pdf:
01659943.pdf:x+2г42T0 AHDRB!9KH%+R)K@@!$
01659944.pdf:
01659945.pdf:

File2.txt
---------
<< /CreationDate (D:20060419121647-05'00') /Title (A 8-32 kbit/s Scalable Wideband Speech and Audio Coding Candidate for ITU-T G729EV Standardization) /Producer (PDFlib+PDI 6.0.3 \(COM/Win32\)) /ModDate (D:20060609142615-04')
<< /CreationDate (D:20060419121647-05'00') /Title (An Embedded Scalable Wideband Codec based on the GSM EFR Codec) /Producer (PDFlib+PDI 6.0.3 \(COM/Win32\)) /ModDate (D:20060609142616-04')
<< /CreationDate (D:20060419121647-05'00') /Title (Multiple Description Coding for Voice over IP using Sinusoidal Speech Coding) /Producer (PDFlib+PDI 6.0.3 \(COM/Win32\)) /ModDate (D:20060609142617-04')
<< /CreationDate (D:20060419121647-05'00') /Title (RESYNCHRONIZATION OF THE ADAPTIVE CODEBOOK IN A CONSTRAINED CELP CODEC AFTER A FRAME ERASURE) /Producer (PDFlib+PDI 6.0.3 \(COM/Win32\)) /ModDate (D:20060609142618-04')

Desired Resultant File (FileR.txt)
======================>
01659942.pdf:A 8-32 kbit/s Scalable Wideband Speech and Audio Coding Candidate for ITU-T G729EV Standardization
01659943.pdf:An Embedded Scalable Wideband Codec based on the GSM EFR Codec
01659944.pdf:Multiple Description Coding for Voice over IP using Sinusoidal Speech Coding
01659945.pdf:RESYNCHRONIZATION OF THE ADAPTIVE CODEBOOK IN A CONSTRAINED CELP CODEC AFTER A FRAME ERASURE

Instructions:
=============
Please cut and paste the contents of the two files in blank text files.

Question
========
I would like to know what is the command required to concatenate the first two files (looks like a vertical concatenation) in order to obtain the desired output file.

I have found a similar post but there is no explanation in that post that will help me extend the logic enumerated in that case to my question. So I shall really appreciate if the person clarifying would be a bit generous with his explanation.

Thanks,
Ingrid

ynodelman 09-18-2012 05:32 AM

Ingrid,

You need to parse both files to temp once, containing just what you need and then "paste" them together:

cut -d":" -f1 <file1> > temp_file1
cut -d"(" -f3 <file2> >temp_file2
cut -d")" -f1 <temp_file2> >temp2_file2
paste -d":" temp_file1 temp2_file2 > result_file

PS: Try one by one command and see on the screen what you're getting
PPS: Always, always create a back-up.


All times are GMT -5. The time now is 12:29 PM.