Need to take out count of various value in linux
Clash Royale CLAN TAG#URR8PPP
up vote
-4
down vote
favorite
aff_id=752&off_id=4503trans_id=acacthf60cxr
aff_id=752&off_id=4553trans_id=acacthf60cxr
aff_id=752&off_id=4543trans_id=acacthf60cxr
aff_id=752&off_id=4543trans_id=acacthf60cxr
aff_id=752&off_id=4553trans_id=acacthf60cxr
aff_id=752&off_id=4503trans_id=acacthf60cxr
aff_id=752&off_id=4513trans_id=acacthf60cxr
aff_id=752&off_id=4513trans_id=acacthf60cxr
aff_id=752&off_id=4503trans_id=acacthf60cxr
this is the format of my file with same aff_id and different "off_id". I need to take out the count of based on "off_id".
shell-script shell text-processing
add a comment |Â
up vote
-4
down vote
favorite
aff_id=752&off_id=4503trans_id=acacthf60cxr
aff_id=752&off_id=4553trans_id=acacthf60cxr
aff_id=752&off_id=4543trans_id=acacthf60cxr
aff_id=752&off_id=4543trans_id=acacthf60cxr
aff_id=752&off_id=4553trans_id=acacthf60cxr
aff_id=752&off_id=4503trans_id=acacthf60cxr
aff_id=752&off_id=4513trans_id=acacthf60cxr
aff_id=752&off_id=4513trans_id=acacthf60cxr
aff_id=752&off_id=4503trans_id=acacthf60cxr
this is the format of my file with same aff_id and different "off_id". I need to take out the count of based on "off_id".
shell-script shell text-processing
1
can you please specify more about the needed output you want to reach? could you also provide a sample output of the above
â GiannakopoulosJ
Oct 16 '17 at 10:31
add a comment |Â
up vote
-4
down vote
favorite
up vote
-4
down vote
favorite
aff_id=752&off_id=4503trans_id=acacthf60cxr
aff_id=752&off_id=4553trans_id=acacthf60cxr
aff_id=752&off_id=4543trans_id=acacthf60cxr
aff_id=752&off_id=4543trans_id=acacthf60cxr
aff_id=752&off_id=4553trans_id=acacthf60cxr
aff_id=752&off_id=4503trans_id=acacthf60cxr
aff_id=752&off_id=4513trans_id=acacthf60cxr
aff_id=752&off_id=4513trans_id=acacthf60cxr
aff_id=752&off_id=4503trans_id=acacthf60cxr
this is the format of my file with same aff_id and different "off_id". I need to take out the count of based on "off_id".
shell-script shell text-processing
aff_id=752&off_id=4503trans_id=acacthf60cxr
aff_id=752&off_id=4553trans_id=acacthf60cxr
aff_id=752&off_id=4543trans_id=acacthf60cxr
aff_id=752&off_id=4543trans_id=acacthf60cxr
aff_id=752&off_id=4553trans_id=acacthf60cxr
aff_id=752&off_id=4503trans_id=acacthf60cxr
aff_id=752&off_id=4513trans_id=acacthf60cxr
aff_id=752&off_id=4513trans_id=acacthf60cxr
aff_id=752&off_id=4503trans_id=acacthf60cxr
this is the format of my file with same aff_id and different "off_id". I need to take out the count of based on "off_id".
shell-script shell text-processing
edited Oct 16 '17 at 12:23
terdonâ¦
123k28231404
123k28231404
asked Oct 16 '17 at 10:26
Rishabh Bahukhandi
334
334
1
can you please specify more about the needed output you want to reach? could you also provide a sample output of the above
â GiannakopoulosJ
Oct 16 '17 at 10:31
add a comment |Â
1
can you please specify more about the needed output you want to reach? could you also provide a sample output of the above
â GiannakopoulosJ
Oct 16 '17 at 10:31
1
1
can you please specify more about the needed output you want to reach? could you also provide a sample output of the above
â GiannakopoulosJ
Oct 16 '17 at 10:31
can you please specify more about the needed output you want to reach? could you also provide a sample output of the above
â GiannakopoulosJ
Oct 16 '17 at 10:31
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
Awk solution:
awk -F'[=&]' ' a[substr($4,0,4)]++ END for(i in a) print i,a[i] ' file
-F'[=&]'
- complex field separatora[substr($4,0,4)]++
-off_id
value is in 4th field$4
and would have format like4503trans_id
.
Therefore,substr($4,0,4)
will extract the needed value4503
.
The arraya
will be indexed withoff_id
values having its occurrences as value
The output:
4503 3
4513 2
4543 2
4553 2
This is right. Could you please explain this command.
â Rishabh Bahukhandi
Oct 16 '17 at 11:03
@RishabhBahukhandi, yes, see my explanation
â RomanPerekhrest
Oct 16 '17 at 12:00
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Awk solution:
awk -F'[=&]' ' a[substr($4,0,4)]++ END for(i in a) print i,a[i] ' file
-F'[=&]'
- complex field separatora[substr($4,0,4)]++
-off_id
value is in 4th field$4
and would have format like4503trans_id
.
Therefore,substr($4,0,4)
will extract the needed value4503
.
The arraya
will be indexed withoff_id
values having its occurrences as value
The output:
4503 3
4513 2
4543 2
4553 2
This is right. Could you please explain this command.
â Rishabh Bahukhandi
Oct 16 '17 at 11:03
@RishabhBahukhandi, yes, see my explanation
â RomanPerekhrest
Oct 16 '17 at 12:00
add a comment |Â
up vote
0
down vote
accepted
Awk solution:
awk -F'[=&]' ' a[substr($4,0,4)]++ END for(i in a) print i,a[i] ' file
-F'[=&]'
- complex field separatora[substr($4,0,4)]++
-off_id
value is in 4th field$4
and would have format like4503trans_id
.
Therefore,substr($4,0,4)
will extract the needed value4503
.
The arraya
will be indexed withoff_id
values having its occurrences as value
The output:
4503 3
4513 2
4543 2
4553 2
This is right. Could you please explain this command.
â Rishabh Bahukhandi
Oct 16 '17 at 11:03
@RishabhBahukhandi, yes, see my explanation
â RomanPerekhrest
Oct 16 '17 at 12:00
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Awk solution:
awk -F'[=&]' ' a[substr($4,0,4)]++ END for(i in a) print i,a[i] ' file
-F'[=&]'
- complex field separatora[substr($4,0,4)]++
-off_id
value is in 4th field$4
and would have format like4503trans_id
.
Therefore,substr($4,0,4)
will extract the needed value4503
.
The arraya
will be indexed withoff_id
values having its occurrences as value
The output:
4503 3
4513 2
4543 2
4553 2
Awk solution:
awk -F'[=&]' ' a[substr($4,0,4)]++ END for(i in a) print i,a[i] ' file
-F'[=&]'
- complex field separatora[substr($4,0,4)]++
-off_id
value is in 4th field$4
and would have format like4503trans_id
.
Therefore,substr($4,0,4)
will extract the needed value4503
.
The arraya
will be indexed withoff_id
values having its occurrences as value
The output:
4503 3
4513 2
4543 2
4553 2
edited Oct 16 '17 at 12:00
answered Oct 16 '17 at 10:35
RomanPerekhrest
22.5k12145
22.5k12145
This is right. Could you please explain this command.
â Rishabh Bahukhandi
Oct 16 '17 at 11:03
@RishabhBahukhandi, yes, see my explanation
â RomanPerekhrest
Oct 16 '17 at 12:00
add a comment |Â
This is right. Could you please explain this command.
â Rishabh Bahukhandi
Oct 16 '17 at 11:03
@RishabhBahukhandi, yes, see my explanation
â RomanPerekhrest
Oct 16 '17 at 12:00
This is right. Could you please explain this command.
â Rishabh Bahukhandi
Oct 16 '17 at 11:03
This is right. Could you please explain this command.
â Rishabh Bahukhandi
Oct 16 '17 at 11:03
@RishabhBahukhandi, yes, see my explanation
â RomanPerekhrest
Oct 16 '17 at 12:00
@RishabhBahukhandi, yes, see my explanation
â RomanPerekhrest
Oct 16 '17 at 12:00
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f398375%2fneed-to-take-out-count-of-various-value-in-linux%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
can you please specify more about the needed output you want to reach? could you also provide a sample output of the above
â GiannakopoulosJ
Oct 16 '17 at 10:31