Re: help for concatenate 2 files

Werfgam Nadler <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
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.


------------------------------------

-- 
Yahoo! Groups Links



[Non-text portions of this message have been removed]
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.