10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I want to find row-wise average of multiple columns based on 2 columns.
I have 30k values in the matrix with 94 cols.
Example Input for cols 4 and 5 as keys
1 2 3 a 1
4 5 6 a 1
4 2 0 a 1
1 2 3 b 2
5 6 7 b 2
9 7 5 b 2
Output
3 3 3 a 1
5 5 5 b 2Here is what I have tried,... (5 Replies)
Discussion started by: ritakadm
5 Replies
2. UNIX for Dummies Questions & Answers
Please suggest a sort command to achieve the below task. Thanks.
I want to sort a file considering multiple keys.
Sort Keys: Field 2, Field4 and Field6
Input file
vqrs,16,zzz,1235,eq,T
abcd,11,zzz,1234,pq,F
abcd,10,zzz,1235,pq,F
lqrs,15,zzz,1235,eq,T
pqrs,12,zzz,1234,eq,F... (3 Replies)
Discussion started by: pretty1234
3 Replies
3. Shell Programming and Scripting
Hi,
I use UBUNTU 12.04.
I have a file with this structure:
Name 2 1245787 A G 12 14 12 14 ....
Name 1 1245789 C T 13 12 12 12.....
I would like to sort my file based on the second column so to have this output for example:
Name 1 1245789 C T 13 12 12 12.....
Name 2 1245787 A G 12 14... (4 Replies)
Discussion started by: Homa
4 Replies
4. Shell Programming and Scripting
I have a file which looks roughly like this:
996 mmmmmmm
996 xxxxxxxxxxxxx
99600 ssssssssss
9964 fffffffffffff
and would like to sort it numerically on the first field. I tried:
sort -nr --key=1 ....
The output I get is:
99600 ssssssssss
9964 ... (3 Replies)
Discussion started by: rovf
3 Replies
5. Shell Programming and Scripting
Can you guys pls take a look at this.
I need to sort this list of numbers as follows:
2nd col first, then 1st col, then 3rd col, all in reverse (highest to lowest).
I'm doing this:
sort -k 2,2nr -k 1,1nr -k 3,3gr
but, as you see, the 3rd col does not get sorted properly.
Any idea... (0 Replies)
Discussion started by: mamboknave
0 Replies
6. Shell Programming and Scripting
Hello
If you wanted to sort a .csv file that was filled with lines like this:
<Ticker>,<Date as YYYYMMDD>,<Time as H:M:S>,<Volume>,<Corr>
(H : , M, S: )
by date, does anybody know of a better solution than to turn the 3rd and 4th colons of every line into commas, sorting on four keys,... (20 Replies)
Discussion started by: Ryan.
20 Replies
7. Shell Programming and Scripting
Hi All
I've got a perl script that I'm having a problem with when it prints the output of a hash. Some background. I'm trying to merge two file with a similar structure but with different data. Here is a portion of the script I'm using.
while (<INPUT>) {
my... (0 Replies)
Discussion started by: kingpin2502
0 Replies
8. Shell Programming and Scripting
hi all,
i have a small problem regarding sorting the keys in a hash.
my %hash;
for($i=0;$i<19;$i++)
{
$hash{$i}=$i;
}
foreach $c (sort keys %hash)
{
print "\n $hash{$c}";
} (1 Reply)
Discussion started by: niteesh_!7
1 Replies
9. Shell Programming and Scripting
Hi,
I would like to do the following sorting, but the output is not what i expected. Why 222 and 2222 are not at the last two elements of array?
awk 'BEGIN{a="22";a="2222";a="33";a="44";a="222";a="11";a="22";a="33";asort(a); for (i=1;i<=8;i++) print a}'
11
22
22
222
2222
33
33
44... (1 Reply)
Discussion started by: phoeberunner
1 Replies
10. UNIX for Advanced & Expert Users
Hello,
Say I have a file with plain text as shown below. Some columns may have multiple words (like "DESC 1", "DESC 1 2", "DESC 1 2 3"). Let's say the file below has 4 columns: 1st(AA), 2nd(BB), 3rd(DESC 1, ...), 4th(CC 1, ...).
1234567890123456789012345678901234567890
AA BB DESC 1... (1 Reply)
Discussion started by: teqmem
1 Replies