[Solved] looping script issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] looping script issue
# 1  
Old 11-10-2011
[Solved] looping script issue

Hi all.. Need your help
I want to combine 2 file into 1file
File1 :
Code:
A
B
C
D

File2 :
Code:
1
2
3
4

Result :
Code:
A1
A2
A3
A4
B1
B2
B3
B4
C1
C2
C3
C4
D1
D2
D3
D4

Pliss help me

Thanks


Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.

Last edited by vbe; 11-10-2011 at 10:24 AM..
# 2  
Old 11-10-2011
Code:
$ while read char; do nawk -v ch=$char '{printf("%s%s\n",ch,$1)}' file2; done < file1
A1
A2
A3
A4
B1
B2
B3
B4
C1
C2
C3
C4
D1
D2
D3
D4

This User Gave Thanks to itkamaraj For This Post:
# 3  
Old 11-10-2011
you are awesome bro itkamaraj.. thanks so much

one question, how about if in my file there is space character. cause it success if in my file there is no space character
# 4  
Old 11-10-2011
Another way:
Code:
 awk 'NR==FNR{a[NR]=$0;z=NR;next}{for (i=1;i<=z;i++){print $0""a[i]}}' file2 file1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell scripting looping issue

#!bin/ksh --------------------------------------------------------------------------------------------- -- Get sequence number from database --------------------------------------------------------------------------------------------- .os rm... (3 Replies)
Discussion started by: swathi reddy1
3 Replies

2. Shell Programming and Scripting

Issue with looping

Hi guys, I am creating a script that checks if a service is UP and running on a bunch of remote servers. My list of servers is: p2 runtime1 8080 p3 runtime2 8080 p4 runtime3 8080 p5 runtime4 8080 p6 runtime5 8080 p7 runtime6 8080 p8 runtime7 8080 p9 runtime8 8080 p10 runtime9 8080... (4 Replies)
Discussion started by: Junaid Subhani
4 Replies

3. Shell Programming and Scripting

[Solved] Issue with grep

Hi everyone I am trying to write a script to check if file systems are mounted, and also validate the permission; then do a whole bunch of other things. I am facing a problem with grep. For example, if the mountpoints are: /dev/XYZ_lv /abc/XYZ jfs2 Nov 25 20:36... (4 Replies)
Discussion started by: nimo
4 Replies

4. Shell Programming and Scripting

Looping in background issue

Background info : Linux machines, /bin/bash shell . I have several remote machines. I want to create a variable for each of these remote machines, by retrieving some data remotely for each of them. As this may take some time for each remote machine, I want to launch these commands woth a for... (2 Replies)
Discussion started by: black_fender
2 Replies

5. Solaris

[SOLVED] Issue with hostname command

Hi, i'm having issues with one of my db servers, each time i run the hostname command i get "-a" as result this is the only zone on this server where i have this issue. could any one help me with this issue (5 Replies)
Discussion started by: EduardoDiaz
5 Replies

6. Shell Programming and Scripting

Odd looping issue with NET::FTP and Proftpd

Hello, I'm a UNIX SysAdmin at a large webhosting company and we have a vendor that provides a service which involves the ftp'ing of files from their servers to ours. They initiate FTP using a perl script with NET::FTP. When they try to transfer files (and delete files over ftp), there is... (3 Replies)
Discussion started by: tmmgeekette
3 Replies

7. Shell Programming and Scripting

[Solved] Looping var from two files

Hey Guys, I have been searching but unable to find solution for this; Got 2 files: #File A A B C #File B 1 2 3 And would like to 'merge' file and get a out put like; A1 A2 A3 B1 (2 Replies)
Discussion started by: bsdguy
2 Replies

8. HP-UX

[Solved] Help with intermittent ping issue

We recently stood up a new server running HP-UX 11.31. Every time we do a restart we lose connectivity to the server. Can't ping in or out. I did some troubleshooting and the problem gets resolved temporarily(can ping in and out and putty to it) when we disconnect the network cable and reconnect... (4 Replies)
Discussion started by: DtbCollumb
4 Replies

9. Shell Programming and Scripting

[Solved] help me in this looping in shell scripting

Hi, #!/bin/ksh result='/TIA/app/UniQP/queue/document/CSB' i=0; while ; do i=`expr $i + 1` if ($i -lt 5);then echo "THerrFile_$i.err"; else break; fi done ... (0 Replies)
Discussion started by: sudhir_83k
0 Replies

10. Solaris

[solved] Jumpstart Profile Issue

I have created profile file for zfs root (flash) on a wanboot server when i try to validate the rules file with check i get following error .. i 'm not sure why i 'm getting this error .. can any one help me on this ? # ./check Validating rules... Validating profile profile... Error in... (0 Replies)
Discussion started by: fugitive
0 Replies
Login or Register to Ask a Question