Re: help for concatenate 2 files

Thierry Blanc <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
other solution:

sed -r 's|([^;]*)\s*;.*|\1;TEST;TEST|' file1 |cat file2  - |sort -n 
|uniq -w 5 | cut -c 5- | paste file1 -

file1: file that has ALL entries
file2: file that has just the additional entries (i.e. not line 8 and 13)



On 04/17/2013 08:05 AM, Werfgam Nadler wrote:
> Hi,
>
> try this solution.
>
> cat   file1   file2  |  sed '
>
> $!{
> N;
> s/^/\n/;
> D
> }
>
> /^\([^\n; ]*\) .*\n\1 /!{
> s/\n/; TEST ; TEST ;&/
> /\n/!s/$/; TEST ; TEST ;/
> }
>
> /^\([^\n; ]*\)\( *\);\([^\n][^\n]*\)\(.*\)\n\1 *\([^\n][^\n]*\)/{
> s//\1\2;\3\5\4/;
> }
> P;
> D;
> '
>
> I got the below result
>
> bug_id ; creation_ts ; bug_severity; bug_when            ; added
> 8    ;  2013-03-21 ; N/A; TEST ; TEST ;
> 9    ;  2013-03-21 ; Mineur; 2013-03-21 15:49:44 ; CONFIRME
> 10  ;  2013-03-21 ; Mineur; 2013-03-21 15:04:56 ; CONFIRME
> 11  ;  2013-03-21 ; Mineur; 2013-03-21 15:56:59 ; CONFIRME
> 12  ;  2013-03-25 ; N/A; 2013-03-25 17:09:09 ; CONFIRME
> 13  ;  2013-03-25 ; N/A; TEST ; TEST ;
>
>
> thanks
> WN
>
>
>
>
>
> ________________________________
>   From: MOKRANI Rachid <[email protected]>
> To: [email protected]
> Sent: Wednesday, March 27, 2013 8:32 PM
> Subject: help for concatenate 2 files
>   
>
> Hi,
>
> I don't know how to concatenate two files with row.
>
> The first file is :
>
> cat /tmp/file1
>
> bug_id ; creation_ts ; bug_severity
> 8    ;   2013-03-21 ; N/A
> 9    ;   2013-03-21 ; Mineur
> 10   ;   2013-03-21 ; Mineur
> 11   ;   2013-03-21 ; Mineur
> 12   ;   2013-03-25 ; N/A
> 13   ;   2013-03-25 ; N/A
>
> The second file is :
>
> cat /tmp/file2
>
> bug_id ; bug_when            ; added
> 9      ; 2013-03-21 15:49:44 ; CONFIRME
> 10     ; 2013-03-21 15:04:56 ; CONFIRME
> 11     ; 2013-03-21 15:56:59 ; CONFIRME
> 12     ; 2013-03-25 17:09:09 ; CONFIRME
>
>
> I don't know how to obtain the following result .
>
> bug_id ; creation_ts ; bug_severity ;  bug_when           ; added    ;
> 8      ; 2013-03-21  ; N/A          ;                     ;          ;
> 9      ; 2013-03-21  ; Mineur       ; 2013-03-21 15:49:44 ; CONFIRME ;
> 10     ; 2013-03-21  ; Mineur       ; 2013-03-21 15:04:56 ; CONFIRME ;
> 11     ; 2013-03-21  ; Mineur       ; 2013-03-21 15:56:59 ; CONFIRME ;
> 12     ; 2013-03-25  ; N/A          ; 2013-03-25 17:09:09 ; CONFIRME ;
> 13     ; 2013-03-25  ; N/A          ;                     ;          ;
>
> OR the following
>
> bug_id ; creation_ts ; bug_severity ;  bug_when           ; added    ;
> 8      ; 2013-03-21  ; N/A          ;     TEST            ; TEST     ;
> 9      ; 2013-03-21  ; Mineur       ; 2013-03-21 15:49:44 ; CONFIRME ;
> 10     ; 2013-03-21  ; Mineur       ; 2013-03-21 15:04:56 ; CONFIRME ;
> 11     ; 2013-03-21  ; Mineur       ; 2013-03-21 15:56:59 ; CONFIRME ;
> 12     ; 2013-03-25  ; N/A          ; 2013-03-25 17:09:09 ; CONFIRME ;
> 13     ; 2013-03-25  ; N/A          ;      TEST           ;  TEST    ;
>
>
> Any help will be really appreciate.
> Best regards.
>
>
> ------------------------------------
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.