The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > AIX
Google UNIX.COM


The 50 most popular UNIX and Linux searches.
Google Search Cloud for The UNIX and Linux Forums
421 service not available, remote server has closed connection ^m automate ftp autosys awk trim bash eval bash for loop boot: cannot open kernel/sparcv9/unix command copy/move folder in unix couldn't set locale correctly curses.h cut command in unix daemon process find grep find mtime find null character in a unix file grep multiple lines grep or grep recursive hp-ux ifconfig inaddr_any inappropriate ioctl for device lynx javascript mailx attachment mget mtime perl array length ping port remove first character from string in k shell replace space by comma , perl script scp recursive segmentation fault(coredump) sftp script snoop unix stale nfs file handle syn_sent tar exclude tar extract to folder test: argument expected unix unix .profile unix forum unix forums unix internals unix interview questions unix mtime unix simulator unix.com vi substitute while loop within while loop shell script

View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #7 (permalink)  
Old 05-09-2008
tagger tagger is offline
Registered User
 

Join Date: May 2008
Posts: 9
it ' s amaising !

On my server (AIX), I have created 4 files :
File1 with the following content :
0507 1202 JOBA
0507 1302 JOBB
0507 1452 JOBC
0507 1552 JOBA
0507 1553 JOBA

File2 :
JOBA abcdefg server4
JOBB defghij server22
JOBC vwxyz12 server55

My script newscript.ksh (chmod u+x newscript.ksh) :
#!/bin/ksh

cat File1 | while read line
do
JOBNAME=$(echo ${line} | awk '{print $3}')
LINE2=$(grep -w $JOBNAME File2 | awk '{print $2 " " $3}')
echo "$line $LINE2" >> File3
done


I'm running the script $PWD/newscript.ksh

So, I have a new file File3 :
# more File3
0507 1202 JOBA abcdefg server4
0507 1302 JOBB defghij server22
0507 1452 JOBC vwxyz12 server55
0507 1552 JOBA abcdefg server4
0507 1553 JOBA abcdefg server4

It's working fine for me.
Reply With Quote