HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Adding the field in 3 files
Operating System - Linux
        1839770
        Members
    
    
        4616
        Online
    
    
        110155
        Solutions
    
Forums
        Categories
Company
Local Language
                
                  
                  back
                
        
                
        
                
        
                
        
        
        
                
        
                
        
        
        
                
        
              
              Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
                
                  
                  back
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
            
                
            
                
            
                
            
                
            
            
                
            
                
            
            
                
            
                
              
            Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
        Information
        Community
Resources
Community Language
        Language
        Forums
Blogs
	
		
			
            
                
            Go to solution
        
            
		
		
			
            	
	
		
        
		
	
	
		Topic Options
			
				
					
	
			
		
	- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2007 05:00 AM
07-25-2007 05:00 AM
			
				
					
					
						I have 3 files these files contains the exactly column like this :
*******************************************
* Name H Fee(1st yr) Scholarship(1styr) *
*******************************************
Steave :7000 :5000
Mike :5000 :2000
Jhon :7000 :3000
and so on
I have simillar 2 more files which have the same columns but for 2nd year and 3rd year in 2nd and 3rd file respectively.
I want a single file which will be containing the name of the candidate ,sum of hostel fee for 3 years, sum of scholarship for three years.
Assuming:
The same names are appering in the 2nd and 3rd file with same order.
	
			
				
		
			
			
			
			
			
			
		
		
		
	
	
	
*******************************************
* Name H Fee(1st yr) Scholarship(1styr) *
*******************************************
Steave :7000 :5000
Mike :5000 :2000
Jhon :7000 :3000
and so on
I have simillar 2 more files which have the same columns but for 2nd year and 3rd year in 2nd and 3rd file respectively.
I want a single file which will be containing the name of the candidate ,sum of hostel fee for 3 years, sum of scholarship for three years.
Assuming:
The same names are appering in the 2nd and 3rd file with same order.
Solved! Go to Solution.
		3 REPLIES 3
	
	            
            
		
		
			
            
                - Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2007 05:28 AM
07-25-2007 05:28 AM
			
				
					
						
							Re: Adding the field in 3 files
						
					
					
				
			
		
	
			
	
	
	
	
	
			
				
					
					
						Can any one reply mw.
How we can add up the colums of 2nd year and 3rd year to first year.
Using awk.I am try to write a shell script for that.
		
		
	
	
	
How we can add up the colums of 2nd year and 3rd year to first year.
Using awk.I am try to write a shell script for that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2007 05:51 AM
07-25-2007 05:51 AM
Solution
			
				
					
					
						Hi:
# awk '{H[$1]+=$2;S[$1]+=$3};END{for (name in H) print name, H[name], S[name]}' file1 file2 file3 > fileout
Any number of file arguments can be passed. It doesn't matter if a name fails to appear in any file, either.
I see that you are new to the Forums. Welcome! Please see:
http://forums1.itrc.hp.com/service/forums/helptips.do?#28
Regards!
...JRF...
		
		
	
	
	
# awk '{H[$1]+=$2;S[$1]+=$3};END{for (name in H) print name, H[name], S[name]}' file1 file2 file3 > fileout
Any number of file arguments can be passed. It doesn't matter if a name fails to appear in any file, either.
I see that you are new to the Forums. Welcome! Please see:
http://forums1.itrc.hp.com/service/forums/helptips.do?#28
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2007 07:00 AM
07-25-2007 07:00 AM
			
				
					
						
							Re: Adding the field in 3 files
						
					
					
				
			
		
	
			
	
	
	
	
	
			
				
					
					
						Thanks a lot boss!
yeah i m new to this form.
I have customize it with accordance to my need.
But u have given a wonderful approach.
ll approach u if i ll not be able to solve any problem my self.
Thanks once again.
					
				
			
			
				
			
			
				
			
			
			
			
			
			
		
		
		
	
	
	
yeah i m new to this form.
I have customize it with accordance to my need.
But u have given a wonderful approach.
ll approach u if i ll not be able to solve any problem my self.
Thanks once again.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
		
	
	
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP
