Re: for loop example

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Sat, Jun 04, 2016 at 11:11:21AM +0530, Indunil Jayasooriya wrote:
> Hi list,
> 
> Can you look in to this?
> 
> 
> [root@centos67 loop]# cat file1
> firstname1
> firstname2
> 
> [root@centos67 loop]# cat file2
> lastname1
> lastname2
> 
> I need a OUTPUT like this
> 
> 
> *firstname1 lastname1firstname2 lastname2*
> 
Assuming your files 1&2 will be longer than 2 lines,
consider this:


paste -d' ' file1 file2 |
    awk '(NR%2) == 1 {l1 = $0; getline ; print l1 $0}'

-- 
Jon H. LaBadie                 jon@xxxxxxxxxx
 11226 South Shore Rd.          (703) 787-0688 (H)
 Reston, VA  20190              (703) 935-6720 (C)
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
https://lists.centos.org/mailman/listinfo/centos



[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux