AWK - How to extract matches including part of filename from multiple filesHow to print the line number when searching for a string in multiple filesCount the number of unique values based on two columns in a spreadsheetsed remove last 2 numeralsPrint a string a number of timesRemove duplicated dots from file nameremove 2nd line of output using awkExtract word from string using grep/sed/awkSearching line by line text between first two matchesawk - compare 2 files and print columns from both filesAWK split output with the line

Is Mortgage interest accrued after a December payment tax deductible?

How could a female member of a species produce eggs unto death?

Can the damage from a Talisman of Pure Good (or Ultimate Evil) be non-lethal?

Did CPM support custom hardware using device drivers?

What are the possible solutions of the given equation?

It's a yearly task, alright

Life insurance that covers only simultaneous/dual deaths

SQL Server Primary Login Restrictions

Identifying the interval from A♭ to D♯

Using "wallow" verb with object

Ban on all campaign finance?

Why did it take so long to abandon sail after steamships were demonstrated?

Be in awe of my brilliance!

How to deal with a cynical class?

How to deal with taxi scam when on vacation?

What is IP squat space

Why do Australian milk farmers need to protest supermarkets' milk price?

Co-worker team leader wants to inject his friend's awful software into our development. What should I say to our common boss?

Why does Deadpool say "You're welcome, Canada," after shooting Ryan Reynolds in the end credits?

How to simplify this time periods definition interface?

An Accountant Seeks the Help of a Mathematician

Employee lack of ownership

Russian cases: A few examples, I'm really confused

Pinhole Camera with Instant Film



AWK - How to extract matches including part of filename from multiple files


How to print the line number when searching for a string in multiple filesCount the number of unique values based on two columns in a spreadsheetsed remove last 2 numeralsPrint a string a number of timesRemove duplicated dots from file nameremove 2nd line of output using awkExtract word from string using grep/sed/awkSearching line by line text between first two matchesawk - compare 2 files and print columns from both filesAWK split output with the line













0















i have 1000 files with filename like this :



total_val_count.html?itemid=5555



with content



total.val="number":1234,"Validation":YES


i want output like this itemid:number using awk



5555:1234


Thanks










share|improve this question







New contributor




H.Otmane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Are you sure that '?' sign is part of your filenames, since it is special to bash shell, or is it excerpt from apache log or something with calls to CGI bin executables?

    – gmt42
    2 hours ago
















0















i have 1000 files with filename like this :



total_val_count.html?itemid=5555



with content



total.val="number":1234,"Validation":YES


i want output like this itemid:number using awk



5555:1234


Thanks










share|improve this question







New contributor




H.Otmane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Are you sure that '?' sign is part of your filenames, since it is special to bash shell, or is it excerpt from apache log or something with calls to CGI bin executables?

    – gmt42
    2 hours ago














0












0








0








i have 1000 files with filename like this :



total_val_count.html?itemid=5555



with content



total.val="number":1234,"Validation":YES


i want output like this itemid:number using awk



5555:1234


Thanks










share|improve this question







New contributor




H.Otmane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












i have 1000 files with filename like this :



total_val_count.html?itemid=5555



with content



total.val="number":1234,"Validation":YES


i want output like this itemid:number using awk



5555:1234


Thanks







grep sed awk






share|improve this question







New contributor




H.Otmane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




H.Otmane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




H.Otmane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 3 hours ago









H.OtmaneH.Otmane

52




52




New contributor




H.Otmane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





H.Otmane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






H.Otmane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Are you sure that '?' sign is part of your filenames, since it is special to bash shell, or is it excerpt from apache log or something with calls to CGI bin executables?

    – gmt42
    2 hours ago


















  • Are you sure that '?' sign is part of your filenames, since it is special to bash shell, or is it excerpt from apache log or something with calls to CGI bin executables?

    – gmt42
    2 hours ago

















Are you sure that '?' sign is part of your filenames, since it is special to bash shell, or is it excerpt from apache log or something with calls to CGI bin executables?

– gmt42
2 hours ago






Are you sure that '?' sign is part of your filenames, since it is special to bash shell, or is it excerpt from apache log or something with calls to CGI bin executables?

– gmt42
2 hours ago











1 Answer
1






active

oldest

votes


















1














If you have GNU Awk:



$ gawk '
BEGINFILE
split(FILENAME,a,/=/)

match($0,/"number":[0-9]+/)
printf "%s:%dn", a[2], substr($0,9+RSTART,RLENGTH)

' total_val*
5555:1234


Or with Perl



$ perl -lnE '$x = (split /=/,$ARGV)[1]; say "$x:$1" if /"number":(d+)/' total_val*
5555:1234


In neither case is any checking done (for example, that the filename splits successfully on an = sign).






share|improve this answer






















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    H.Otmane is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1125752%2fawk-how-to-extract-matches-including-part-of-filename-from-multiple-files%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    If you have GNU Awk:



    $ gawk '
    BEGINFILE
    split(FILENAME,a,/=/)

    match($0,/"number":[0-9]+/)
    printf "%s:%dn", a[2], substr($0,9+RSTART,RLENGTH)

    ' total_val*
    5555:1234


    Or with Perl



    $ perl -lnE '$x = (split /=/,$ARGV)[1]; say "$x:$1" if /"number":(d+)/' total_val*
    5555:1234


    In neither case is any checking done (for example, that the filename splits successfully on an = sign).






    share|improve this answer



























      1














      If you have GNU Awk:



      $ gawk '
      BEGINFILE
      split(FILENAME,a,/=/)

      match($0,/"number":[0-9]+/)
      printf "%s:%dn", a[2], substr($0,9+RSTART,RLENGTH)

      ' total_val*
      5555:1234


      Or with Perl



      $ perl -lnE '$x = (split /=/,$ARGV)[1]; say "$x:$1" if /"number":(d+)/' total_val*
      5555:1234


      In neither case is any checking done (for example, that the filename splits successfully on an = sign).






      share|improve this answer

























        1












        1








        1







        If you have GNU Awk:



        $ gawk '
        BEGINFILE
        split(FILENAME,a,/=/)

        match($0,/"number":[0-9]+/)
        printf "%s:%dn", a[2], substr($0,9+RSTART,RLENGTH)

        ' total_val*
        5555:1234


        Or with Perl



        $ perl -lnE '$x = (split /=/,$ARGV)[1]; say "$x:$1" if /"number":(d+)/' total_val*
        5555:1234


        In neither case is any checking done (for example, that the filename splits successfully on an = sign).






        share|improve this answer













        If you have GNU Awk:



        $ gawk '
        BEGINFILE
        split(FILENAME,a,/=/)

        match($0,/"number":[0-9]+/)
        printf "%s:%dn", a[2], substr($0,9+RSTART,RLENGTH)

        ' total_val*
        5555:1234


        Or with Perl



        $ perl -lnE '$x = (split /=/,$ARGV)[1]; say "$x:$1" if /"number":(d+)/' total_val*
        5555:1234


        In neither case is any checking done (for example, that the filename splits successfully on an = sign).







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 hours ago









        steeldriversteeldriver

        69.2k11114185




        69.2k11114185




















            H.Otmane is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            H.Otmane is a new contributor. Be nice, and check out our Code of Conduct.












            H.Otmane is a new contributor. Be nice, and check out our Code of Conduct.











            H.Otmane is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1125752%2fawk-how-to-extract-matches-including-part-of-filename-from-multiple-files%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Are there any comparative studies done between Ashtavakra Gita and Buddhim?How is it wrong to believe that a self exists, or that it doesn't?Can you criticise or improve Ven. Bodhi's description of MahayanaWas the doctrine of 'Anatta', accepted as doctrine by modern Buddhism, actually taught by the Buddha?Relationship between Buddhism, Hinduism and Yoga?Comparison of Nirvana, Tao and Brahman/AtmaIs there a distinction between “ego identity” and “craving/hating”?Are there many differences between Taoism and Buddhism?Loss of “faith” in buddhismSimilarity between creation in Abrahamic religions and beginning of life in Earth mentioned Agganna Sutta?Are there studies about the difference between meditating in the morning versus in the evening?Can one follow Hinduism and Buddhism at the same time?Are there any prohibitions on participating in other religion's practices?Psychology of 'flow'

            Where else does the Shulchan Aruch quote an authority by name?Parashat Metzora+HagadolPesach/PassoverShulchan Aruch UTF-8Anonymous glosses in the Shulchan AruchWhy is the Shulchan Aruch definitive?Siman 32, Kitzur Shulchan Aruch: UntranslatedLitvaks/Yeshivish and Shulchan AruchBuying a Shulchan AruchEnglish version of SHULCHAN ARUCHIs there any place where Shulchan Aruch rules with the Rosh against the Rif and Rambam?Are there practices where Sepharadim do not hold by Shulchan Aruch?5th part of the shulchan aruch

            fallocate: fallocate failed: Text file busy in Ubuntu 17.04? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)defragmenting and increasing performance of old lubuntu system with swap partitionIssue with increasing the root partition from the swapthis /usr/bin/dpkg returned error || ubuntu-16.04, 64bitDefault 17.04 swap file locationHow to Resize Ubuntu 17.04 Zesty Swap file size?Ubuntu freezes from online formsMy Laptop is not starting after upgrade ubuntu 16.04 (Kernel 4.8.0-38 to 04.10.0-36)hcp: ERROR: FALLOCATE FAILED!Not sure my swap is being usedWine 3.0 asking for more virtual free swap