Search Results

Search: Posts Made By: lucasvs
3,074
Posted By lucasvs
Explanation on problem "match" function awk
Hello Unix experts,

If I could get any explanations on why the code below doesn't work it would be great !

My input looks like that ("|" delimited):
Saaaaabbbbbccccc|ok
Sdddddfffffggggg|ok
...
2,068
Posted By lucasvs
So you mean I should 1st) sort by field1 and...
So you mean I should
1st) sort by field1 and generate a first output
2nd) use this output to sort by subfield 2 and generate the final output.

I tried things like below but still doesn't work....
2,068
Posted By lucasvs
gawk asort to sort record groups based on one subfield
input ("/" delimited fields):
style1/book1 (author_C)/editor1/2000
style1/book2 (author_A)/editor2/2004
style1/book3 (author_B)/editor3/2001
style2/book8 (author_B)/editor4/2010
style2/book5...
1,961
Posted By lucasvs
It depends. I would need to put the task I...
It depends. I would need to put the task I described in my first post into a function as it is a recurrent task in the script.
So my question is: can you write a part of a function in the END...
1,961
Posted By lucasvs
alister: this task will be part of a function as...
alister: this task will be part of a function as I have to repeat it multiple times. Can a function refer to rules written in an END block?

Rudic: Thanks for your help. I understand the approach...
1,961
Posted By lucasvs
It is part of a bigger script with several...
It is part of a bigger script with several redirections, just to keep it simple
1,961
Posted By lucasvs
Sorting arrays horizontally without END section, awk
input:
ref001, Europe, Belgium, 1001
ref001, Europe, Spain, 203
ref001, Europe, Germany, 457
ref002, America, Canada, 234
ref002, America, US, 87
ref002, America, Alaska, 652

Without using...
1,090
Posted By lucasvs
Thanks Don Cragun and spacebar ! But is it...
Thanks Don Cragun and spacebar !

But is it possible without using an END section?
1,090
Posted By lucasvs
And without using an END section, is it...
And without using an END section, is it doable...:)
1,090
Posted By lucasvs
removing newlines without changing RS in BEGIN
Using awk, is there a way to remove newlines in strings that don't contain 1_ at the beginning, but without setting RS="1_" in the BEGIN section and without using a END section as well?

input:...
986
Posted By lucasvs
Ok, I was wondering if there was a built-in...
Ok, I was wondering if there was a built-in variable like FILENAME but for the other way
:wall:

Thanks anyway !
986
Posted By lucasvs
redirect to a file based on a value in a field
Hi all!

Is it possible with awk to redirect all the records of a file that match a string in a field to a specific file.

input.tab:
aaaaa|bbbbbb|KKKKK
cccccc|dddddd|SSSSS...
2,221
Posted By lucasvs
Ok I get it ! So, if I understood well, if I...
Ok I get it !

So, if I understood well, if I am sure that my input will contain only one character per field, with the same number of columns for every line, I can use this code instead:
...
2,221
Posted By lucasvs
Thanks elixir ! However, i don't understand...
Thanks elixir !

However, i don't understand the point of
if(NF>max) max=NF

Why not just use i<=NF directly in the END section ?

AND

start=match(a[i],$i)
if(start &&...
2,221
Posted By lucasvs
It leaves the first ",": blue|,red,green ...
It leaves the first ",":

blue|,red,green

---------- Post updated at 01:54 AM ---------- Previous update was at 01:43 AM ----------

However, elixir_sinari's code works for a file with 2...
2,221
Posted By lucasvs
Hi rangarasan ! Your code returns: b ...
Hi rangarasan !

Your code returns:

b
blue|red,red,green,red

Without the ";", it suppresses the first "b" but only list the second column:

blue|red,red,green,red

That's the role of
...
2,221
Posted By lucasvs
Thanks elixir_sinari ! Can you tell me what...
Thanks elixir_sinari !

Can you tell me what a[$1] stands for ?

Does it mean "the first column"?
2,221
Posted By lucasvs
Compare values of fields from same column with awk
Hi all !

If there is only one single value in a column (e.g. column 1 below), then return this value in the same output column.
If there are several values in the same column (e.g. column 2...
2,321
Posted By lucasvs
Great ! Thanks! but what is the...
Great !

Thanks!

but what is the function of the "return" statement?
2,321
Posted By lucasvs
Ok, but How do you call the function? I...
Ok, but How do you call the function?

I tried with:
{b = split($2,a,", ")
for (i=1; i<=b; i++){
n = a[i]

convert($2)

}
}1

{b =...
2,321
Posted By lucasvs
Hi Peasant ! Thanks for your advices. ...
Hi Peasant !

Thanks for your advices.

However when I use only the codes of the function it prints the original line in record 1, and then the wanted line in record2 !!!!

And when I use the...
2,321
Posted By lucasvs
Hi Scrutinizer ! So I tried: ...
Hi Scrutinizer !



So I tried:
#!/usr/bin/gawk -f

BEGIN{FS=OFS="|"}

n = split($2,a,", ")
for (i=1; i<=n; i++){

if (a[i] < 3999) {
...
2,321
Posted By lucasvs
Hi balajesuri ! ok, I see
Hi balajesuri !

ok, I see
2,321
Posted By lucasvs
Problem syntax with user-defined function
Hi !

I got a script from [Arabic to Roman numeral conversion - .comp.lang.awk (http://www.freag.net/en/t/1k9s2/arabic_to_roman), that I would like to modify to apply it on my input file.

input...
1,649
Posted By lucasvs
You're absolutely right ! Thanks agama
You're absolutely right !

Thanks agama
Showing results 1 to 25 of 85

 

Featured Tech Videos

All times are GMT -4. The time now is 06:19 AM.
Unix & Linux Forums Content Copyright 1993-2019. All Rights Reserved.
Privacy Policy