Search Results

Search: Posts Made By: beca123456
2,132
Posted By beca123456
I see my mistake. Thanks !
I see my mistake. Thanks !
2,132
Posted By beca123456
Your code works. Thanks ! But I would like to...
Your code works. Thanks !
But I would like to understand why mine does not. It seems fine to me...
2,132
Posted By beca123456
Discarding records with duplicate fields
Hi,

My input looks like this (tab-delimited):
grp1 name2 firstname M 55 item1 item1.0
grp1 name2 firstname F 55 item1 item1.0
grp2 name1 firstname M 55 item1 item1.0...
2,183
Posted By beca123456
Brilliant ! However, although I think I...
Brilliant !

However, although I think I understand the following lines, I cannot place them in the context:
# When reading the input file for the first time, create an array based on $1 for which...
2,183
Posted By beca123456
Replace substring by longest string in common field (awk)
Hi,

Let's say I have a pipe-separated input like so:
name_10|A|BCCC|cat_1
name_11|B|DE|cat_2
name_10|A|BC|cat_3
name_11|B|DEEEEEE|cat_4

Using awk, for records with common field 2, I am...
920
Posted By beca123456
Works great ! Thanks !
Works great ! Thanks !
920
Posted By beca123456
Awk: output lines with common field to separate files
Hi,

A beginner one.

my input.tab (tab-separated):
h1 h2 h3 h4 h5
item1 grpA 2 3 customer1
item2 grpB 4 6 customer1
item3 grpA 5 9 customer1
item4 grpA 0 0 customer2...
1,128
Posted By beca123456
Very good point ! I got it now, thanks !
Very good point !
I got it now, thanks !
1,128
Posted By beca123456
I don't understand this statement. Both solutions...
I don't understand this statement. Both solutions seem to work just fine.
Is one more prone to errors than the other?
1,128
Posted By beca123456
Awk: group multiple fields from different records
Hi,

My input looks like that:
A|123|qwer
A|456|tyui
A|456|wsxe
B|789|dfgh

Using awk, I am trying to get:
A|123;456|qwer;tyui;wsxe
B|789|dfgh
For records with same $1, group all the $2 in...
1,360
Posted By beca123456
Awk: greater than sign is working upside down
Hi,

I noticed a weird behaviour with awk.

input:
A|B|1-100|blabla_35_40_blabla;blabla_53_60_blabla;blabla_90_110_blabla

Objective:
For each string separated by ';' in $4, if the first and...
2,113
Posted By beca123456
Sorry, I am stupid... No "_" between "@" and...
Sorry, I am stupid...

No "_" between "@" and "val"

Sorry again

Note: I had to upgrade gawk to version 4 to get PROCINFO working
2,113
Posted By beca123456
Gawk: PROCINFO["sorted_in"] does not sort my numerical array values
Hi,

PROCINFO seems to be a great function but I don't manage to make it works.

input:
B,A,C
B
B,B

As an example, just want to count the occurence of each letter across the input and sort...
4,667
Posted By beca123456
Very useful information. Thanks !
Very useful information. Thanks !
4,667
Posted By beca123456
I did not know the 'delete' function. It's great...
I did not know the 'delete' function. It's great !

I did not know neither the form '!count[b[i]]++' instead of 'count[b[i]]++==0'

Thanks !
4,667
Posted By beca123456
Awk: count unique elements in a field and sum their occurence across the entire file
Hi,

Sure it's an easy one, but it drives me insane.

input ("|" separated):
1|A,B,C,A
2|A,D,D
3|A,B,B

I would like to count the occurence of each capital letters in $2 across the entire...
3,074
Posted By beca123456
Thanks RudiC, However I should have insisted...
Thanks RudiC,

However I should have insisted on the second criteria ("$3 of file2 is present in $2 of file1"). Meaning that I am not looking for an exact match.

For example if file1.tab is:...
3,074
Posted By beca123456
Awk: matching multiple fields between 2 files
Hi,

I have 2 tab-delimited input files as follows.
file1.tab:
green A apple
red B apple

file2.tab:
apple - A;Z

Objective:
Return $1 of file1 if,
. $1 of file2 matches $3 of file1 and,...
5,863
Posted By beca123456
Thanks guys ! Everything works great !
Thanks guys !
Everything works great !
5,863
Posted By beca123456
Awk: count unique element of array
Hi,

tab-separated input:
blabla_1 A,B,C,C
blabla_2 A,E,G
blabla_3 R,Q,A,B,C,R,Q

output:
blabla_1 3
blabla_2 3
blabla_3 5

After splitting $2 in an array, I am trying to store the number...
3,060
Posted By beca123456
Thanks Don Cragun, this is brilliant !
Thanks Don Cragun, this is brilliant !
3,060
Posted By beca123456
Correct. This is a typo. My code should have...
Correct. This is a typo. My code should have been:
gawk 'BEGIN{FS=OFS="|"; start=2; end=5}{for(i=start; i<=end; i++){var=sprintf("%s%s",$i, i<end ? OFS : "\n")}; common[var] = common[var]...
3,060
Posted By beca123456
Thanks for your help ! However, the point of...
Thanks for your help !

However, the point of my post was to use sprintf to store the identical fields in a variable ($2, $3, $4, $5 here). I need to use sprintf because in my real file there are...
3,060
Posted By beca123456
Awk: subset of fields as variable with sprint
Dear Unix Gurus,

input:
A|1|2|3|4|5
B|1|2|3|4|3
C|1|2|3|4|1
D|1|9|3|4|12

output:
A_(5);B(3);C(1)|1|2|3|4
D_(12)|1|9|3|4

Details:
If $2, $3, $3, $5 are identical, concatenate $1 and...
2,901
Posted By beca123456
Alright. I understand. Thanks RudiC !
Alright. I understand. Thanks RudiC !
Showing results 1 to 25 of 123

 
All times are GMT -4. The time now is 07:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy