06-23-2009
Quote:
Originally Posted by
Franklin52
If you understand the code you're using for the first column, you should be able to sum up the other columns too. Use 2 more arrays for the other columns.
Regards
Hi Frank,
i tried many ways, but failed. like
awk '{A[$1" "$2" "$3" "$4" "$5"\t"]+=$2;B[$1" "$2" "$3" "$4" "$5"\t"]+=$3}END{for (i in A){print i" "A[i]" "B[i]}}' filea fileb
awk '{A[$1" "$2" "$3" "$4" "$5"\t"]+=$2$3}END{for (i in A){print i" "A[i]" "B[i]}}' filea fileb
and others, but cannot, i think i cannot understand very well on this script. Please advice me.
Thanks
---------- Post updated at 03:28 AM ---------- Previous update was at 03:18 AM ----------
I know the way already:
awk '{A[$1" "$2" "$3" "$4" "$5"\t"]+=$6$7$8}END{for (i in A){print i" "A[i]}}' filea fileb
But the output is
Sun Jun 21 11:47:17 2009 334455
Sun Jun 21 14:37:56 2009 246
Sun Jun 21 11:47:16 2009 234
how to become below?
Sun Jun 21 11:47:17 2009 33 44 55
Sun Jun 21 14:37:56 2009 2 4 6
Sun Jun 21 11:47:16 2009 2 3 4
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi Guys :),
I have two files.
filea:
12:20:23 4
12:21:23 3
12:22:23 2
12:25:23 3
fileb:
11:20:23 4
12:21:23 3
12:22:23 2
12:26:23 3
12:30:23 3
The result will be:
11:20:23 4
12:20:23 4 (3 Replies)
Discussion started by: jimmy_y
3 Replies
2. Shell Programming and Scripting
Hi Everyone,
I have a txt file with 40k lines.
111 1.1.1.1
111 1.1.1.1
111 2.2.2.2
111 1.1.1.1
111 1.1.1.1
How would use perl to easy have IP list, the final result will be:
1.1.1.1,2.2.2.2,
I can only think using if to determine one by one through all 40k, this is working, but... (10 Replies)
Discussion started by: jimmy_y
10 Replies
3. UNIX for Advanced & Expert Users
Hi All,
I have two files
file1:
abc,def,ghi,5,jkl,mno
pqr,stu,ghi,10,vwx,xyz
cba,ust,ihg,4,cdu,oqw
file2:
ravi,def,kishore
ramu,ust,krishna
joseph,stu,mike
I need two output files as follows
In my above example, each row in file1 has 6 fields and each row in file2 has 3... (1 Reply)
Discussion started by: yerruhari
1 Replies
4. UNIX for Dummies Questions & Answers
Hi All,
I have two files
file1:
abc,def,ghi,5,jkl,mno
pqr,stu,ghi,10,vwx,xyz
cba,ust,ihg,4,cdu,oqw
file2:
ravi,def,kishore
ramu,ust,krishna
joseph,stu,mike
I need two output files as follows
In my above example, each row in file1 has 6 fields and each row in file2 has 3... (1 Reply)
Discussion started by: yerruhari
1 Replies
5. Shell Programming and Scripting
Hi All,
I have two files
file1:
abc,def,ghi,5,jkl,mno
pqr,stu,ghi,10,vwx,xyz
cba,ust,ihg,4,cdu,oqw
file2:
ravi,def,kishore
ramu,ust,krishna
joseph,stu,mike
I need two output files as follows
In my above example, each row in file1 has 6 fields and each row in file2 has 3... (3 Replies)
Discussion started by: yerruhari
3 Replies
6. Shell Programming and Scripting
Hi All,
I have two files and data looks like this:
File1 Contents
#Field1,Field2
Dist_Center_file1.txt;21
Dist_Center_file3.txt;20
Dist_Center_file2.txt;20
File2 Contents (*** No Header ***)
Dist_Center_file1.txt;23
Dist_Center_file2.txt;20
Dist_Center_file3.txt;20
I have... (4 Replies)
Discussion started by: Hangman2
4 Replies
7. UNIX for Dummies Questions & Answers
Hi,
I need help on appending certain field in my file1.txt based on matched patterns in file2.txt using awk or sed.
The blue color need to match with one of the data in field $2 in file2.txt. If match, BEGIN and FINISHED value in red will have a new value from field $3 and $4 accordingly.
... (1 Reply)
Discussion started by: redse171
1 Replies
8. Shell Programming and Scripting
Hi,
I need help to find values between two different fields based on $6 (NUM) AND $1 (CD), within the same ID. The result should show the values between the NUMs which will be extracted from within $3 and $2 in data.txt file below.
data.txt
ex 139 142 Sc_1000004 ID 4
CD ... (2 Replies)
Discussion started by: redse171
2 Replies
9. Shell Programming and Scripting
Hi everybody (first time posting here)
I have a file1 that looks like >
1,101,0.1,0.1
1,26,0.1,0.1
1,3,0.1,0.1
1,97,0.5,0.5
1,98,8.1,0.218919
1,99,6.2,0.248
2,101,0.1,0.1
2,24,3.1,0.147619
2,25,23.5,0.559524
2,26,34,0.723404with 762 lines..
I have another 'similar' file2 >
... (10 Replies)
Discussion started by: murpholinox
10 Replies
10. UNIX for Beginners Questions & Answers
Hi,
Below are the sample files. x.txt is from an Excel file that is a list of users from Windows and y.txt is a list of database account.
$ head -500 x.txt y.txt
==> x.txt <==
TEST01 APP_USER_PROFILE
USER03 APP_USER_PROFILE
TEST02 APP_USER_EXP_PROFILE
TEST04 APP_USER_PROFILE
USER01 ... (3 Replies)
Discussion started by: newbie_01
3 Replies
LEARN ABOUT OPENSOLARIS
clusters
clusters(4) Sun Cluster File Formats clusters(4)
NAME
clusters - cluster names database
SYNOPSIS
/etc/clusters
DESCRIPTION
The clusters file contains information regarding the known clusters in the local naming domain. For each cluster a single line should be
present with the following information:
clustername whitespace-delimited list of hosts
Expansion is recursive if a name on the right hand side is tagged with the expansion marker: ``*''.
Items are separated by any number of blanks and/or TAB characters. A `#' indicates the beginning of a comment. Characters up to the end of
the line are not interpreted by routines which search the file.
Cluster names may contain any printable character other than an upper case character, a field delimiter, NEWLINE, or comment character. The
maximum length of a cluster name is 32 characters.
This information is used by Sun Cluster system administration tools, like cconsole(1M) to specify a group of nodes to administer. The
names used in this database must be host names, as used in the hosts database.
The database is available from either NIS or NIS+ maps or a local file. Lookup order can be specified in the /etc/nsswitch.conf file. The
default order is nis files.
EXAMPLES
Example 1 A Sample /etc/clusters File
Here is a typical /etc/clusters file:
bothclusters *planets *wine
planets mercury venus
wine zinfandel merlot chardonnay riesling
Here is a typical /etc/nsswitch.conf entry:
clusters: nis files
FILES
/etc/clusters
/etc/nsswitch.conf
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWsczu |
+-----------------------------+-----------------------------+
|Interface Stability |Uncommitted |
+-----------------------------+-----------------------------+
SEE ALSO
cconsole(1M), chosts(1M), serialports(4), nsswitch.conf(4), attributes(5)
Sun Cluster 3.2 26 Jun 2006 clusters(4)