Grep word within a file then copy the file












8















I have a collection of files ( *.zip, *.txt, *.tar.gz, *.doc, ...etc ). These files reside within a path. I want to find all the files ( *.txt), then copy, only, the text files that contain specific words ( e.g LINUX/UNIX).



I ran the following:



find . -name "*.txt" | grep 'LINUX/UNIX'


This command was able to find all the text files, then "grep" filtered the resultant text files by listing only the text files that contain 'LINUX/UNIX'.



How can I copy these final files (i.e. the text files that contain 'LINUX/UNIX') to a specific path of choice?



I tried to apply xargs



find . -name "*.txt" | grep 'LINUX/UNIX' | xargs cp <to a path>


But it didn't work










share|improve this question

























  • Pretty much the same as Grep command to find files containing text string and move them

    – don_crissti
    Jul 20 '16 at 16:41
















8















I have a collection of files ( *.zip, *.txt, *.tar.gz, *.doc, ...etc ). These files reside within a path. I want to find all the files ( *.txt), then copy, only, the text files that contain specific words ( e.g LINUX/UNIX).



I ran the following:



find . -name "*.txt" | grep 'LINUX/UNIX'


This command was able to find all the text files, then "grep" filtered the resultant text files by listing only the text files that contain 'LINUX/UNIX'.



How can I copy these final files (i.e. the text files that contain 'LINUX/UNIX') to a specific path of choice?



I tried to apply xargs



find . -name "*.txt" | grep 'LINUX/UNIX' | xargs cp <to a path>


But it didn't work










share|improve this question

























  • Pretty much the same as Grep command to find files containing text string and move them

    – don_crissti
    Jul 20 '16 at 16:41














8












8








8


1






I have a collection of files ( *.zip, *.txt, *.tar.gz, *.doc, ...etc ). These files reside within a path. I want to find all the files ( *.txt), then copy, only, the text files that contain specific words ( e.g LINUX/UNIX).



I ran the following:



find . -name "*.txt" | grep 'LINUX/UNIX'


This command was able to find all the text files, then "grep" filtered the resultant text files by listing only the text files that contain 'LINUX/UNIX'.



How can I copy these final files (i.e. the text files that contain 'LINUX/UNIX') to a specific path of choice?



I tried to apply xargs



find . -name "*.txt" | grep 'LINUX/UNIX' | xargs cp <to a path>


But it didn't work










share|improve this question
















I have a collection of files ( *.zip, *.txt, *.tar.gz, *.doc, ...etc ). These files reside within a path. I want to find all the files ( *.txt), then copy, only, the text files that contain specific words ( e.g LINUX/UNIX).



I ran the following:



find . -name "*.txt" | grep 'LINUX/UNIX'


This command was able to find all the text files, then "grep" filtered the resultant text files by listing only the text files that contain 'LINUX/UNIX'.



How can I copy these final files (i.e. the text files that contain 'LINUX/UNIX') to a specific path of choice?



I tried to apply xargs



find . -name "*.txt" | grep 'LINUX/UNIX' | xargs cp <to a path>


But it didn't work







text-processing grep find cp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 14 '18 at 16:36

























asked Jul 20 '16 at 0:41







user88036




















  • Pretty much the same as Grep command to find files containing text string and move them

    – don_crissti
    Jul 20 '16 at 16:41



















  • Pretty much the same as Grep command to find files containing text string and move them

    – don_crissti
    Jul 20 '16 at 16:41

















Pretty much the same as Grep command to find files containing text string and move them

– don_crissti
Jul 20 '16 at 16:41





Pretty much the same as Grep command to find files containing text string and move them

– don_crissti
Jul 20 '16 at 16:41










4 Answers
4






active

oldest

votes


















18














Try:



grep -rl --null --include '*.txt' LINUX/UNIX . | xargs -0r cp -t /path/to/dest


Because this command uses NUL-separation, it is safe for all file names including those with difficult names that include blanks, tabs, or even newlines.



The above requires GNU cp. For MacOS/FreeBSD, try:



grep -rl --null --include '*.txt' LINUX/UNIX . | xargs -0 sh -c 'cp "$@" /path/to/dest' sh


How it works:





  1. grep options and arguments




    • -r tells grep to search recursively through the directory structure. (On FreeBSD, -r will follow symlinks into directories. This is not true of either OS/X or recent versions of GNU grep.)


    • --include '*.txt' tells grep to only return files whose names match the glob *.txt (including hidden ones like .foo.txt or .txt).


    • -l tells grep to only return the names of matching files, not the match itself.


    • --null tells grep to use NUL characters to separate the file names. (--null is supported by grep under GNU/Linux, MacOS and FreeBSD but not OpenBSD.)


    • LINUX/UNIX tells grep to look only for files whose contents include the regex LINUX/UNIX


    • . search in the current directory. You can omit it in recent versions of GNU grep, but then you'd need to pass a -- option terminator to cp to guard against file names that start with -.





  2. xargs options and arguments




    • -0 tells xargs to expect NUL-separated input.


    • -r tells xargs not to run the command unless at least one file was found. (This option is not needed on either BSD or OSX and is not compatible with OSX's xargs.)


    • cp -t /path/to/dest copies the directories to the target directory. (-t requires GNU cp.)









share|improve this answer


























  • For Mac OS X, and probably BSD, you'll want to use --null instead of -Z. Also, I think cp -t is Linux-only.

    – Edward Falk
    Jul 20 '16 at 2:18








  • 1





    @EdwardFalk Good point. Thanks. I updated to use --null and added a version for BSD/OSX that does not use cp -t.

    – John1024
    Jul 20 '16 at 2:27











  • @StéphaneChazelas Thank you for the improvements.

    – John1024
    Jul 20 '16 at 18:40






  • 1





    OpenBSD grep does not have --null.

    – Kusalananda
    May 5 '18 at 20:30











  • @Kusalananda Thanks. Answer updated to note that OpenBSD does not support --null.

    – John1024
    May 6 '18 at 1:48



















13














More portably (POSIX features only):



find . -type f -name '*.txt' -exec grep -q LINUX/UNIX {} ; -exec cp {} /path/to/dest ;





share|improve this answer

































    3














    The following sh/Bash one liner is another method, though will only work in the current directory, and doesn't recurse:



    for f in ./*.txt; do if grep -l 'LINUX/UNIX' "$f"; then cp "$f" /path/to/dest/; fi; done


    The -l option to grep will print a list of the files which are being copied, though you could use -q if you don't want to see anything on the screen.






    share|improve this answer

































      0














      I am not sure why the original string did not work. Following command works for me.



      find / -name (filename*) | grep '(filename.extention)'| xargs cp -t ./



      In my case filename* is collection of files with same name with different file types (txt, zip, etc). I do grep to find out only filename.txt and copy it to my destination directory (which is currently, ./).






      share|improve this answer








      New contributor




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




















        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
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f297006%2fgrep-word-within-a-file-then-copy-the-file%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown
























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        18














        Try:



        grep -rl --null --include '*.txt' LINUX/UNIX . | xargs -0r cp -t /path/to/dest


        Because this command uses NUL-separation, it is safe for all file names including those with difficult names that include blanks, tabs, or even newlines.



        The above requires GNU cp. For MacOS/FreeBSD, try:



        grep -rl --null --include '*.txt' LINUX/UNIX . | xargs -0 sh -c 'cp "$@" /path/to/dest' sh


        How it works:





        1. grep options and arguments




          • -r tells grep to search recursively through the directory structure. (On FreeBSD, -r will follow symlinks into directories. This is not true of either OS/X or recent versions of GNU grep.)


          • --include '*.txt' tells grep to only return files whose names match the glob *.txt (including hidden ones like .foo.txt or .txt).


          • -l tells grep to only return the names of matching files, not the match itself.


          • --null tells grep to use NUL characters to separate the file names. (--null is supported by grep under GNU/Linux, MacOS and FreeBSD but not OpenBSD.)


          • LINUX/UNIX tells grep to look only for files whose contents include the regex LINUX/UNIX


          • . search in the current directory. You can omit it in recent versions of GNU grep, but then you'd need to pass a -- option terminator to cp to guard against file names that start with -.





        2. xargs options and arguments




          • -0 tells xargs to expect NUL-separated input.


          • -r tells xargs not to run the command unless at least one file was found. (This option is not needed on either BSD or OSX and is not compatible with OSX's xargs.)


          • cp -t /path/to/dest copies the directories to the target directory. (-t requires GNU cp.)









        share|improve this answer


























        • For Mac OS X, and probably BSD, you'll want to use --null instead of -Z. Also, I think cp -t is Linux-only.

          – Edward Falk
          Jul 20 '16 at 2:18








        • 1





          @EdwardFalk Good point. Thanks. I updated to use --null and added a version for BSD/OSX that does not use cp -t.

          – John1024
          Jul 20 '16 at 2:27











        • @StéphaneChazelas Thank you for the improvements.

          – John1024
          Jul 20 '16 at 18:40






        • 1





          OpenBSD grep does not have --null.

          – Kusalananda
          May 5 '18 at 20:30











        • @Kusalananda Thanks. Answer updated to note that OpenBSD does not support --null.

          – John1024
          May 6 '18 at 1:48
















        18














        Try:



        grep -rl --null --include '*.txt' LINUX/UNIX . | xargs -0r cp -t /path/to/dest


        Because this command uses NUL-separation, it is safe for all file names including those with difficult names that include blanks, tabs, or even newlines.



        The above requires GNU cp. For MacOS/FreeBSD, try:



        grep -rl --null --include '*.txt' LINUX/UNIX . | xargs -0 sh -c 'cp "$@" /path/to/dest' sh


        How it works:





        1. grep options and arguments




          • -r tells grep to search recursively through the directory structure. (On FreeBSD, -r will follow symlinks into directories. This is not true of either OS/X or recent versions of GNU grep.)


          • --include '*.txt' tells grep to only return files whose names match the glob *.txt (including hidden ones like .foo.txt or .txt).


          • -l tells grep to only return the names of matching files, not the match itself.


          • --null tells grep to use NUL characters to separate the file names. (--null is supported by grep under GNU/Linux, MacOS and FreeBSD but not OpenBSD.)


          • LINUX/UNIX tells grep to look only for files whose contents include the regex LINUX/UNIX


          • . search in the current directory. You can omit it in recent versions of GNU grep, but then you'd need to pass a -- option terminator to cp to guard against file names that start with -.





        2. xargs options and arguments




          • -0 tells xargs to expect NUL-separated input.


          • -r tells xargs not to run the command unless at least one file was found. (This option is not needed on either BSD or OSX and is not compatible with OSX's xargs.)


          • cp -t /path/to/dest copies the directories to the target directory. (-t requires GNU cp.)









        share|improve this answer


























        • For Mac OS X, and probably BSD, you'll want to use --null instead of -Z. Also, I think cp -t is Linux-only.

          – Edward Falk
          Jul 20 '16 at 2:18








        • 1





          @EdwardFalk Good point. Thanks. I updated to use --null and added a version for BSD/OSX that does not use cp -t.

          – John1024
          Jul 20 '16 at 2:27











        • @StéphaneChazelas Thank you for the improvements.

          – John1024
          Jul 20 '16 at 18:40






        • 1





          OpenBSD grep does not have --null.

          – Kusalananda
          May 5 '18 at 20:30











        • @Kusalananda Thanks. Answer updated to note that OpenBSD does not support --null.

          – John1024
          May 6 '18 at 1:48














        18












        18








        18







        Try:



        grep -rl --null --include '*.txt' LINUX/UNIX . | xargs -0r cp -t /path/to/dest


        Because this command uses NUL-separation, it is safe for all file names including those with difficult names that include blanks, tabs, or even newlines.



        The above requires GNU cp. For MacOS/FreeBSD, try:



        grep -rl --null --include '*.txt' LINUX/UNIX . | xargs -0 sh -c 'cp "$@" /path/to/dest' sh


        How it works:





        1. grep options and arguments




          • -r tells grep to search recursively through the directory structure. (On FreeBSD, -r will follow symlinks into directories. This is not true of either OS/X or recent versions of GNU grep.)


          • --include '*.txt' tells grep to only return files whose names match the glob *.txt (including hidden ones like .foo.txt or .txt).


          • -l tells grep to only return the names of matching files, not the match itself.


          • --null tells grep to use NUL characters to separate the file names. (--null is supported by grep under GNU/Linux, MacOS and FreeBSD but not OpenBSD.)


          • LINUX/UNIX tells grep to look only for files whose contents include the regex LINUX/UNIX


          • . search in the current directory. You can omit it in recent versions of GNU grep, but then you'd need to pass a -- option terminator to cp to guard against file names that start with -.





        2. xargs options and arguments




          • -0 tells xargs to expect NUL-separated input.


          • -r tells xargs not to run the command unless at least one file was found. (This option is not needed on either BSD or OSX and is not compatible with OSX's xargs.)


          • cp -t /path/to/dest copies the directories to the target directory. (-t requires GNU cp.)









        share|improve this answer















        Try:



        grep -rl --null --include '*.txt' LINUX/UNIX . | xargs -0r cp -t /path/to/dest


        Because this command uses NUL-separation, it is safe for all file names including those with difficult names that include blanks, tabs, or even newlines.



        The above requires GNU cp. For MacOS/FreeBSD, try:



        grep -rl --null --include '*.txt' LINUX/UNIX . | xargs -0 sh -c 'cp "$@" /path/to/dest' sh


        How it works:





        1. grep options and arguments




          • -r tells grep to search recursively through the directory structure. (On FreeBSD, -r will follow symlinks into directories. This is not true of either OS/X or recent versions of GNU grep.)


          • --include '*.txt' tells grep to only return files whose names match the glob *.txt (including hidden ones like .foo.txt or .txt).


          • -l tells grep to only return the names of matching files, not the match itself.


          • --null tells grep to use NUL characters to separate the file names. (--null is supported by grep under GNU/Linux, MacOS and FreeBSD but not OpenBSD.)


          • LINUX/UNIX tells grep to look only for files whose contents include the regex LINUX/UNIX


          • . search in the current directory. You can omit it in recent versions of GNU grep, but then you'd need to pass a -- option terminator to cp to guard against file names that start with -.





        2. xargs options and arguments




          • -0 tells xargs to expect NUL-separated input.


          • -r tells xargs not to run the command unless at least one file was found. (This option is not needed on either BSD or OSX and is not compatible with OSX's xargs.)


          • cp -t /path/to/dest copies the directories to the target directory. (-t requires GNU cp.)










        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 6 '18 at 1:54

























        answered Jul 20 '16 at 0:59









        John1024John1024

        46k4107122




        46k4107122













        • For Mac OS X, and probably BSD, you'll want to use --null instead of -Z. Also, I think cp -t is Linux-only.

          – Edward Falk
          Jul 20 '16 at 2:18








        • 1





          @EdwardFalk Good point. Thanks. I updated to use --null and added a version for BSD/OSX that does not use cp -t.

          – John1024
          Jul 20 '16 at 2:27











        • @StéphaneChazelas Thank you for the improvements.

          – John1024
          Jul 20 '16 at 18:40






        • 1





          OpenBSD grep does not have --null.

          – Kusalananda
          May 5 '18 at 20:30











        • @Kusalananda Thanks. Answer updated to note that OpenBSD does not support --null.

          – John1024
          May 6 '18 at 1:48



















        • For Mac OS X, and probably BSD, you'll want to use --null instead of -Z. Also, I think cp -t is Linux-only.

          – Edward Falk
          Jul 20 '16 at 2:18








        • 1





          @EdwardFalk Good point. Thanks. I updated to use --null and added a version for BSD/OSX that does not use cp -t.

          – John1024
          Jul 20 '16 at 2:27











        • @StéphaneChazelas Thank you for the improvements.

          – John1024
          Jul 20 '16 at 18:40






        • 1





          OpenBSD grep does not have --null.

          – Kusalananda
          May 5 '18 at 20:30











        • @Kusalananda Thanks. Answer updated to note that OpenBSD does not support --null.

          – John1024
          May 6 '18 at 1:48

















        For Mac OS X, and probably BSD, you'll want to use --null instead of -Z. Also, I think cp -t is Linux-only.

        – Edward Falk
        Jul 20 '16 at 2:18







        For Mac OS X, and probably BSD, you'll want to use --null instead of -Z. Also, I think cp -t is Linux-only.

        – Edward Falk
        Jul 20 '16 at 2:18






        1




        1





        @EdwardFalk Good point. Thanks. I updated to use --null and added a version for BSD/OSX that does not use cp -t.

        – John1024
        Jul 20 '16 at 2:27





        @EdwardFalk Good point. Thanks. I updated to use --null and added a version for BSD/OSX that does not use cp -t.

        – John1024
        Jul 20 '16 at 2:27













        @StéphaneChazelas Thank you for the improvements.

        – John1024
        Jul 20 '16 at 18:40





        @StéphaneChazelas Thank you for the improvements.

        – John1024
        Jul 20 '16 at 18:40




        1




        1





        OpenBSD grep does not have --null.

        – Kusalananda
        May 5 '18 at 20:30





        OpenBSD grep does not have --null.

        – Kusalananda
        May 5 '18 at 20:30













        @Kusalananda Thanks. Answer updated to note that OpenBSD does not support --null.

        – John1024
        May 6 '18 at 1:48





        @Kusalananda Thanks. Answer updated to note that OpenBSD does not support --null.

        – John1024
        May 6 '18 at 1:48













        13














        More portably (POSIX features only):



        find . -type f -name '*.txt' -exec grep -q LINUX/UNIX {} ; -exec cp {} /path/to/dest ;





        share|improve this answer






























          13














          More portably (POSIX features only):



          find . -type f -name '*.txt' -exec grep -q LINUX/UNIX {} ; -exec cp {} /path/to/dest ;





          share|improve this answer




























            13












            13








            13







            More portably (POSIX features only):



            find . -type f -name '*.txt' -exec grep -q LINUX/UNIX {} ; -exec cp {} /path/to/dest ;





            share|improve this answer















            More portably (POSIX features only):



            find . -type f -name '*.txt' -exec grep -q LINUX/UNIX {} ; -exec cp {} /path/to/dest ;






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 9 '16 at 9:28

























            answered Jul 20 '16 at 1:43









            WildcardWildcard

            22.7k962164




            22.7k962164























                3














                The following sh/Bash one liner is another method, though will only work in the current directory, and doesn't recurse:



                for f in ./*.txt; do if grep -l 'LINUX/UNIX' "$f"; then cp "$f" /path/to/dest/; fi; done


                The -l option to grep will print a list of the files which are being copied, though you could use -q if you don't want to see anything on the screen.






                share|improve this answer






























                  3














                  The following sh/Bash one liner is another method, though will only work in the current directory, and doesn't recurse:



                  for f in ./*.txt; do if grep -l 'LINUX/UNIX' "$f"; then cp "$f" /path/to/dest/; fi; done


                  The -l option to grep will print a list of the files which are being copied, though you could use -q if you don't want to see anything on the screen.






                  share|improve this answer




























                    3












                    3








                    3







                    The following sh/Bash one liner is another method, though will only work in the current directory, and doesn't recurse:



                    for f in ./*.txt; do if grep -l 'LINUX/UNIX' "$f"; then cp "$f" /path/to/dest/; fi; done


                    The -l option to grep will print a list of the files which are being copied, though you could use -q if you don't want to see anything on the screen.






                    share|improve this answer















                    The following sh/Bash one liner is another method, though will only work in the current directory, and doesn't recurse:



                    for f in ./*.txt; do if grep -l 'LINUX/UNIX' "$f"; then cp "$f" /path/to/dest/; fi; done


                    The -l option to grep will print a list of the files which are being copied, though you could use -q if you don't want to see anything on the screen.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Jul 20 '16 at 15:23









                    Stéphane Chazelas

                    301k55564916




                    301k55564916










                    answered Jul 20 '16 at 9:16









                    ArronicalArronical

                    235111




                    235111























                        0














                        I am not sure why the original string did not work. Following command works for me.



                        find / -name (filename*) | grep '(filename.extention)'| xargs cp -t ./



                        In my case filename* is collection of files with same name with different file types (txt, zip, etc). I do grep to find out only filename.txt and copy it to my destination directory (which is currently, ./).






                        share|improve this answer








                        New contributor




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

























                          0














                          I am not sure why the original string did not work. Following command works for me.



                          find / -name (filename*) | grep '(filename.extention)'| xargs cp -t ./



                          In my case filename* is collection of files with same name with different file types (txt, zip, etc). I do grep to find out only filename.txt and copy it to my destination directory (which is currently, ./).






                          share|improve this answer








                          New contributor




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























                            0












                            0








                            0







                            I am not sure why the original string did not work. Following command works for me.



                            find / -name (filename*) | grep '(filename.extention)'| xargs cp -t ./



                            In my case filename* is collection of files with same name with different file types (txt, zip, etc). I do grep to find out only filename.txt and copy it to my destination directory (which is currently, ./).






                            share|improve this answer








                            New contributor




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










                            I am not sure why the original string did not work. Following command works for me.



                            find / -name (filename*) | grep '(filename.extention)'| xargs cp -t ./



                            In my case filename* is collection of files with same name with different file types (txt, zip, etc). I do grep to find out only filename.txt and copy it to my destination directory (which is currently, ./).







                            share|improve this answer








                            New contributor




                            SamL 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 answer



                            share|improve this answer






                            New contributor




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









                            answered Jan 9 at 22:08









                            SamLSamL

                            1




                            1




                            New contributor




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





                            New contributor





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






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






























                                draft saved

                                draft discarded




















































                                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%2f297006%2fgrep-word-within-a-file-then-copy-the-file%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

                                How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

                                is 'sed' thread safe

                                How to make a Squid Proxy server?