If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > awk getline

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-29-04, 14:23
fla5do fla5do is offline
Registered User
 
Join Date: Oct 2003
Location: Germany
Posts: 138
awk getline

Hi,
how can I set FS for the lines which given in getline variable x

#cat zahlung.neu | awk ' BEGIN { FS="@"}
# {
# # print $0
# close("patient.neu")
# while ( (getline x < "patient.neu") > 0)
# {
# if (substr(x,1,7) == $2)
# {
# # print substr(x,9)
# name = substr(x,9)
# print name"@"$0 > "zahlung.neu1"
# break
# }
# }
# }'

Thanx
__________________
Greetings from germany
Peter F.
Reply With Quote
  #2 (permalink)  
Old 03-29-04, 15:23
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
You read the file patient.neu for every record in zahlung.neu ....
Instead, you can use the method illustrated by the following script.
Code:
awk '
# Initialize FS for first file
BEGIN {
  FS = "/"
}

# Memorize Names from first file
FNR==NR {
  Name[$1] = $2;
  next;
}

# Set FS and OFS for second file
FNR==1  {
  FS  = "@";
  OFS = "@";
}

# Select record where Name is present in first file
$2 in Name {
    print Name[$2],$0;
}
 ' patient.neu zahlung.neu > zahlung.neu1
__________________
Jean-Pierre.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On