The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
update base mleplawy Shell Programming and Scripting 6 06-02-2008 10:14 AM
Getting data into and out of an OpenOffice.org Base database iBot UNIX and Linux RSS News 0 04-23-2008 11:50 AM
Update NIS+ data djunerup SUN Solaris 0 03-26-2008 07:37 AM
Using loop reading a file,retrieving data from data base. Sonu4lov Shell Programming and Scripting 1 01-18-2007 11:38 PM
data base arunkumar_mca High Level Programming 2 12-29-2004 02:56 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-31-2008
Registered User
 

Join Date: May 2008
Posts: 11
data base update

hello everyone
I need to update data base in file

1-ID
2-Name
3-ID group
4-ID teacher
5-mark list

unique ID is (ID+ID group+ID teacher)
we can append 5 th columns (marks list)

main base file:
Code:
Code:
1:John:3:1:4 3 2
2:Mark:1:2:1 3
3:Susan:3:4:
input file:
Code:
2:Mark:1:2:1 3 5 6
3:Susan:3:4:2 4 3
main base file after update:

Code:
1:John:3:1:4 3 2
2:Mark:1:2:1 3 5 6
3:Susan:3:4:2 4 3
I have a problem with add files to array and with compare student ID
Code:
awk 'BEGIN {x=0}{z=0}{y=0}

{getline base[x++] < "base" }

{getline input[z++] < "input" }
 
END
{for (i in base)
    for(n in input)
	if (base[i]==input[n]) //I now, it's not OK column 1,3,4 must be ==
	    output[y++]=input[n]
	else
	    output[y++]=base[i]
}	

{for (z in output)
print output[z] > "base"}'
Forum Sponsor
  #2 (permalink)  
Old 05-31-2008
Moderator
 

Join Date: Feb 2007
Posts: 1,988
No duplicate or cross-posting, read the rules.

This is a similar post:

update base

Thread closed.
Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:28 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0