Need to take out count of various value in linux

The name of the pictureThe name of the pictureThe name of the pictureClash 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".







share|improve this question


















  • 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















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".







share|improve this question


















  • 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













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".







share|improve this question














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".









share|improve this question













share|improve this question




share|improve this question








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













  • 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











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 separator


  • a[substr($4,0,4)]++ - off_id value is in 4th field $4 and would have format like 4503trans_id.
    Therefore, substr($4,0,4) will extract the needed value 4503.
    The array a will be indexed with off_id values having its occurrences as value



The output:



4503 3
4513 2
4543 2
4553 2





share|improve this answer






















  • 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










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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






























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 separator


  • a[substr($4,0,4)]++ - off_id value is in 4th field $4 and would have format like 4503trans_id.
    Therefore, substr($4,0,4) will extract the needed value 4503.
    The array a will be indexed with off_id values having its occurrences as value



The output:



4503 3
4513 2
4543 2
4553 2





share|improve this answer






















  • 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














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 separator


  • a[substr($4,0,4)]++ - off_id value is in 4th field $4 and would have format like 4503trans_id.
    Therefore, substr($4,0,4) will extract the needed value 4503.
    The array a will be indexed with off_id values having its occurrences as value



The output:



4503 3
4513 2
4543 2
4553 2





share|improve this answer






















  • 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












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 separator


  • a[substr($4,0,4)]++ - off_id value is in 4th field $4 and would have format like 4503trans_id.
    Therefore, substr($4,0,4) will extract the needed value 4503.
    The array a will be indexed with off_id values having its occurrences as value



The output:



4503 3
4513 2
4543 2
4553 2





share|improve this answer














Awk solution:



awk -F'[=&]' ' a[substr($4,0,4)]++ END for(i in a) print i,a[i] ' file


  • -F'[=&]' - complex field separator


  • a[substr($4,0,4)]++ - off_id value is in 4th field $4 and would have format like 4503trans_id.
    Therefore, substr($4,0,4) will extract the needed value 4503.
    The array a will be indexed with off_id values having its occurrences as value



The output:



4503 3
4513 2
4543 2
4553 2






share|improve this answer














share|improve this answer



share|improve this answer








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
















  • 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

















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?