Searching all downloaded files in a file list

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I've downloaded some files. I want to find out whether these file names are present in file.txt one by one. I've tried following command but not successful. I want to find out using xargs.

ls | xargs grep file.txt

How do I do that?







share|improve this question
























    up vote
    0
    down vote

    favorite












    I've downloaded some files. I want to find out whether these file names are present in file.txt one by one. I've tried following command but not successful. I want to find out using xargs.

    ls | xargs grep file.txt

    How do I do that?







    share|improve this question






















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I've downloaded some files. I want to find out whether these file names are present in file.txt one by one. I've tried following command but not successful. I want to find out using xargs.

      ls | xargs grep file.txt

      How do I do that?







      share|improve this question












      I've downloaded some files. I want to find out whether these file names are present in file.txt one by one. I've tried following command but not successful. I want to find out using xargs.

      ls | xargs grep file.txt

      How do I do that?









      share|improve this question











      share|improve this question




      share|improve this question










      asked Oct 28 '17 at 11:05









      Nayab Basha Sayed

      1035




      1035




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          Though I'm not sure what exactly means your "one by one" but here is



          Short ls + grep approach:



          ls -1 | grep -wf - file.txt



          • -1 - ls option, lists one file per line


          • -f file - grep option, obtains patterns from file(or STDIN in case of passing - argument), one per line



          The same could be written as:



          grep -wf <(ls -1) file.txt





          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',
            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%2f401044%2fsearching-all-downloaded-files-in-a-file-list%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










            Though I'm not sure what exactly means your "one by one" but here is



            Short ls + grep approach:



            ls -1 | grep -wf - file.txt



            • -1 - ls option, lists one file per line


            • -f file - grep option, obtains patterns from file(or STDIN in case of passing - argument), one per line



            The same could be written as:



            grep -wf <(ls -1) file.txt





            share|improve this answer


























              up vote
              0
              down vote



              accepted










              Though I'm not sure what exactly means your "one by one" but here is



              Short ls + grep approach:



              ls -1 | grep -wf - file.txt



              • -1 - ls option, lists one file per line


              • -f file - grep option, obtains patterns from file(or STDIN in case of passing - argument), one per line



              The same could be written as:



              grep -wf <(ls -1) file.txt





              share|improve this answer
























                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                Though I'm not sure what exactly means your "one by one" but here is



                Short ls + grep approach:



                ls -1 | grep -wf - file.txt



                • -1 - ls option, lists one file per line


                • -f file - grep option, obtains patterns from file(or STDIN in case of passing - argument), one per line



                The same could be written as:



                grep -wf <(ls -1) file.txt





                share|improve this answer














                Though I'm not sure what exactly means your "one by one" but here is



                Short ls + grep approach:



                ls -1 | grep -wf - file.txt



                • -1 - ls option, lists one file per line


                • -f file - grep option, obtains patterns from file(or STDIN in case of passing - argument), one per line



                The same could be written as:



                grep -wf <(ls -1) file.txt






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Oct 28 '17 at 11:23

























                answered Oct 28 '17 at 11:11









                RomanPerekhrest

                22.5k12145




                22.5k12145



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f401044%2fsearching-all-downloaded-files-in-a-file-list%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?