for loop example

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



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*


But I try the below command , i get below output.  what is the real command
to get the above output

[root@centos67 loop]# for line1 in $(cat file1 ); do for line2 in $(cat
file2 ); do echo "$line1" "$line2";done;done;
firstname1 lastname1
firstname1 lastname2
firstname2 lastname1
firstname2 lastname2


And also, I created a file3 like this

[root@centos67 loop]# cat file3
firstname1 lastname1
firstname2 lastname2

How can I get the same OUTPUT ?


*firstname1 lastname1firstname2 lastname2*


if I try below command, i get the below output.

[root@centos67 loop]# for i in $(cat file3);do echo $i;done;
firstname1
lastname1
firstname2
lastname2


Could you pls help me to solve this ? THIS is very important to me.









-- 
cat /etc/motd

Thank you
Indunil Jayasooriya
http://www.theravadanet.net/
http://www.siyabas.lk/sinhala_how_to_install.html   -  Download Sinhala
Fonts
_______________________________________________
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