You didn't answer the question: "Will all lines for a given group be adjacent (as in your example), or will data for various groups be intermixed?" so I tried to write code that would work either way. Note that the order of the groups in the output from this is random. It uses two dimensional arrays to keep track of the sums and counts for each column and group. (If all lines for a group are adjacent, you could still use one-dimensional arrays and dump the data for each group when a new group is found.)
Given that both entries in the 3rd column for group ru are -9, I don't understand why you believe the output for that column for that group should be 2; the following code produces 0 in this case:
Using awk on macOS 10.12.1, I get the output:
in average.csv with the sample input.csv data you provided in post #3.
AWK subtraction in multiple columns
Hi there,
Can not get the following:
input: 34523 934
9485 3847
394 3847
3456 9384
awk 'NR==1 {for (i = 1; i <= NF; i++) {n=$i; next}; {n-=$i} END {print n}' input
output: 21188 first column only,... (2 Replies)
Hi,
I'm trying to reformat a file to create a new columns reflecting the previous 2 over and over. By that I mean currently each observation has two columns and I want to create a third which has a value equal to 1 minus the sum of the previous two.
This is slightly complicated as 1) I... (6 Replies)
I can't seem to get this to work.
I can reformat the date field if it's the first field (and only field) in the file:
However, I get a syntax error when the date field is the second field (or has any other columns following):
I can use a ";" but then it puts each column on separate... (8 Replies)
Hi everyone!!
I need to apply a simple command to extract columns from a matrix, but I need to extract contemporary from the first to the tenth columns, than from the eleventh to the twentyth and so on...
how can i do that? (1 Reply)
Hi All,
I need the modification for the below mentioned code (found in one more post https://www.unix.com/shell-programming-scripting/27161-script-generate-average-values.html) to find the average values for all the columns(but for a specific rows) and print the averages side by side.
I have... (4 Replies)
Hi experts,
I want to group by average, for multiple columns starting column $7 until NF,
group by ($1-$5), please help
For just 7th column, I can do
awk '
NR>1{
arr += $7
count += 1
}
END{
for (a in arr) {
print a, arr/count
... (10 Replies)
I have the following format of input from multiple files
File 1
24.01 -81.01 1.0
24.02 -81.02 5.0
24.03 -81.03 0.0
File 2
24.01 -81.01 2.0
24.02 -81.02 -5.0
24.03 -81.03 10.0
I need to scan through the files and when the first 2 columns match I... (18 Replies)
Hi guys,
I have hundreds file like this, here I only show two of them:
file 1
feco4_s_BB95.log ZE_1=-1717.5206260
feco4_t_BB95.log ZE_1=-1717.5169250
feco5_s_BB95.log ZE_1=-1830.9322060... (11 Replies)
Hello All;
I have two files with below conditions:
1. Entries in file A is missing in file B (primary is field 1)
2. Entries in file B is missing in file A (primary is field 1)
3. Field 1 is present in both files but Field 2 is different.
Example Content:
File A
... (4 Replies)
Discussion started by: mystition
4 Replies
LEARN ABOUT REDHAT
groupdel
GROUPDEL(8) System Manager's Manual GROUPDEL(8)NAME
groupdel - Delete a group
SYNOPSIS
groupdel group
DESCRIPTION
The groupdel command modifies the system account files, deleting all entries that refer to group. The named group must exist.
You must manually check all filesystems to insure that no files remain with the named group as the file group ID.
CAVEATS
You may not remove the primary group of any existing user. You must remove the user before you remove the group.
FILES
/etc/group - group information
/etc/gshadow - secure group information
SEE ALSO chfn(1), chsh(1), passwd(1), groupadd(8), groupmod(8), useradd(8), userdel(8), usermod(8)AUTHOR
Julianne Frances Haugh (jockgrrl@ix.netcom.com)
GROUPDEL(8)