Get text from file matching specific line numbers?Print nth line before the matched line, Matching line and nth line from the matched lineHow to read a text file line by line which is not constant in shell scriptingShell program which reads line and output lines with the line numbersCreating a text file from other text filesGet specific line below grepped lineHow to execute a find command using a set of strings from a line in a text filematch specific line and print all lines except the following lineBash script Multiply only numbers from a text file?Need shell script to read line with matching contentFind and copy text from one file to another

Examples of smooth manifolds admitting inbetween one and a continuum of complex structures

How do conventional missiles fly?

How dangerous is XSS?

Alternative to sending password over mail?

If human space travel is limited by the G force vulnerability, is there a way to counter G forces?

In 'Revenger,' what does 'cove' come from?

What reasons are there for a Capitalist to oppose a 100% inheritance tax?

Is there a hemisphere-neutral way of specifying a season?

What about the virus in 12 Monkeys?

How much of data wrangling is a data scientist's job?

Expand and Contract

Do UK voters know if their MP will be the Speaker of the House?

Why didn't Boeing produce its own regional jet?

Watching something be piped to a file live with tail

All in one piece, we mend holes in your socks

Why doesn't using multiple commands with a || or && conditional work?

Arrow those variables!

Why is this clock signal connected to a capacitor to gnd?

What is the most common color to indicate the input-field is disabled?

How would I stat a creature to be immune to everything but the Magic Missile spell? (just for fun)

What is a romance in Latin?

Little known, relatively unlikely, but scientifically plausible, apocalyptic (or near apocalyptic) events

Is there an expression that means doing something right before you will need it rather than doing it in case you might need it?

Why would the Red Woman birth a shadow if she worshipped the Lord of the Light?



Get text from file matching specific line numbers?


Print nth line before the matched line, Matching line and nth line from the matched lineHow to read a text file line by line which is not constant in shell scriptingShell program which reads line and output lines with the line numbersCreating a text file from other text filesGet specific line below grepped lineHow to execute a find command using a set of strings from a line in a text filematch specific line and print all lines except the following lineBash script Multiply only numbers from a text file?Need shell script to read line with matching contentFind and copy text from one file to another













0















How can a script get the line number(s) of sentences with words length less than 20, then use those line numbers to get the text from another file with those line numbers?



awk 'if (NF<20) print NR' filename will get sentences with length less than 20 words and print the line number, but how would a script use its output to get sentences matching those lines numbers from another file?










share|improve this question









New contributor




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















  • 3





    Please click edit then tell us what you have tried so far, and what the result was. Please also provide examples, as your question is not very understandable.

    – K7AAY
    2 days ago







  • 3





    Yes, do provide examples of data. Also, the awk code you show will count words (by default these would be whitespace delimited strings) on the current line, not necessarily in a sentence.

    – Kusalananda
    2 days ago















0















How can a script get the line number(s) of sentences with words length less than 20, then use those line numbers to get the text from another file with those line numbers?



awk 'if (NF<20) print NR' filename will get sentences with length less than 20 words and print the line number, but how would a script use its output to get sentences matching those lines numbers from another file?










share|improve this question









New contributor




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















  • 3





    Please click edit then tell us what you have tried so far, and what the result was. Please also provide examples, as your question is not very understandable.

    – K7AAY
    2 days ago







  • 3





    Yes, do provide examples of data. Also, the awk code you show will count words (by default these would be whitespace delimited strings) on the current line, not necessarily in a sentence.

    – Kusalananda
    2 days ago













0












0








0








How can a script get the line number(s) of sentences with words length less than 20, then use those line numbers to get the text from another file with those line numbers?



awk 'if (NF<20) print NR' filename will get sentences with length less than 20 words and print the line number, but how would a script use its output to get sentences matching those lines numbers from another file?










share|improve this question









New contributor




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












How can a script get the line number(s) of sentences with words length less than 20, then use those line numbers to get the text from another file with those line numbers?



awk 'if (NF<20) print NR' filename will get sentences with length less than 20 words and print the line number, but how would a script use its output to get sentences matching those lines numbers from another file?







shell-script






share|improve this question









New contributor




mocarsha2019 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




mocarsha2019 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








edited 2 days ago









K7AAY

909928




909928






New contributor




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









asked 2 days ago









mocarsha2019mocarsha2019

12




12




New contributor




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





New contributor





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






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







  • 3





    Please click edit then tell us what you have tried so far, and what the result was. Please also provide examples, as your question is not very understandable.

    – K7AAY
    2 days ago







  • 3





    Yes, do provide examples of data. Also, the awk code you show will count words (by default these would be whitespace delimited strings) on the current line, not necessarily in a sentence.

    – Kusalananda
    2 days ago












  • 3





    Please click edit then tell us what you have tried so far, and what the result was. Please also provide examples, as your question is not very understandable.

    – K7AAY
    2 days ago







  • 3





    Yes, do provide examples of data. Also, the awk code you show will count words (by default these would be whitespace delimited strings) on the current line, not necessarily in a sentence.

    – Kusalananda
    2 days ago







3




3





Please click edit then tell us what you have tried so far, and what the result was. Please also provide examples, as your question is not very understandable.

– K7AAY
2 days ago






Please click edit then tell us what you have tried so far, and what the result was. Please also provide examples, as your question is not very understandable.

– K7AAY
2 days ago





3




3





Yes, do provide examples of data. Also, the awk code you show will count words (by default these would be whitespace delimited strings) on the current line, not necessarily in a sentence.

– Kusalananda
2 days ago





Yes, do provide examples of data. Also, the awk code you show will count words (by default these would be whitespace delimited strings) on the current line, not necessarily in a sentence.

– Kusalananda
2 days ago










1 Answer
1






active

oldest

votes


















0














FNR = File Number Record, is the current line number in the context of the current file



NR = Number Record, is the line number total



Passing both files to awk and using a comparison to detect the file change, this is going to store the line number of file1 in an array if the Field Number is less than 20 and print the line of file2 if it is in the array



awk 'FNR==NRif (NF<20) lines[NR]="1"; nextif (FNR in lines) print' file1 file2





share|improve this answer























    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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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
    );



    );






    mocarsha2019 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%2funix.stackexchange.com%2fquestions%2f509906%2fget-text-from-file-matching-specific-line-numbers%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









    0














    FNR = File Number Record, is the current line number in the context of the current file



    NR = Number Record, is the line number total



    Passing both files to awk and using a comparison to detect the file change, this is going to store the line number of file1 in an array if the Field Number is less than 20 and print the line of file2 if it is in the array



    awk 'FNR==NRif (NF<20) lines[NR]="1"; nextif (FNR in lines) print' file1 file2





    share|improve this answer



























      0














      FNR = File Number Record, is the current line number in the context of the current file



      NR = Number Record, is the line number total



      Passing both files to awk and using a comparison to detect the file change, this is going to store the line number of file1 in an array if the Field Number is less than 20 and print the line of file2 if it is in the array



      awk 'FNR==NRif (NF<20) lines[NR]="1"; nextif (FNR in lines) print' file1 file2





      share|improve this answer

























        0












        0








        0







        FNR = File Number Record, is the current line number in the context of the current file



        NR = Number Record, is the line number total



        Passing both files to awk and using a comparison to detect the file change, this is going to store the line number of file1 in an array if the Field Number is less than 20 and print the line of file2 if it is in the array



        awk 'FNR==NRif (NF<20) lines[NR]="1"; nextif (FNR in lines) print' file1 file2





        share|improve this answer













        FNR = File Number Record, is the current line number in the context of the current file



        NR = Number Record, is the line number total



        Passing both files to awk and using a comparison to detect the file change, this is going to store the line number of file1 in an array if the Field Number is less than 20 and print the line of file2 if it is in the array



        awk 'FNR==NRif (NF<20) lines[NR]="1"; nextif (FNR in lines) print' file1 file2






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 days ago









        DalvenjiaDalvenjia

        1,23658




        1,23658




















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









            draft saved

            draft discarded


















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












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











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














            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • 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%2funix.stackexchange.com%2fquestions%2f509906%2fget-text-from-file-matching-specific-line-numbers%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

            getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

            Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

            Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.