Cannot cat file which has space in name in linux












3















I believe there's a simple fix but cannot debug it out.



I have file called "file name with space"
How do I cat this file from Linux bash ?










share|improve this question













migrated from stackoverflow.com Jun 12 '13 at 20:14


This question came from our site for professional and enthusiast programmers.














  • 2





    cat "file name with space" or cat file name with space

    – ctn
    Jun 12 '13 at 18:22






  • 2





    cat "file with space" doesn't work!? Good luck.

    – shellter
    Jun 12 '13 at 18:22











  • Sure: name your file file_name_with_underscore...

    – H2CO3
    Jun 12 '13 at 18:27











  • @H2CO3 Why if it works if everythin is implemented well?

    – glglgl
    Jun 12 '13 at 18:34











  • @glglgl Safe, convenient, cross-platform and idiomatic.

    – H2CO3
    Jun 12 '13 at 18:35
















3















I believe there's a simple fix but cannot debug it out.



I have file called "file name with space"
How do I cat this file from Linux bash ?










share|improve this question













migrated from stackoverflow.com Jun 12 '13 at 20:14


This question came from our site for professional and enthusiast programmers.














  • 2





    cat "file name with space" or cat file name with space

    – ctn
    Jun 12 '13 at 18:22






  • 2





    cat "file with space" doesn't work!? Good luck.

    – shellter
    Jun 12 '13 at 18:22











  • Sure: name your file file_name_with_underscore...

    – H2CO3
    Jun 12 '13 at 18:27











  • @H2CO3 Why if it works if everythin is implemented well?

    – glglgl
    Jun 12 '13 at 18:34











  • @glglgl Safe, convenient, cross-platform and idiomatic.

    – H2CO3
    Jun 12 '13 at 18:35














3












3








3








I believe there's a simple fix but cannot debug it out.



I have file called "file name with space"
How do I cat this file from Linux bash ?










share|improve this question














I believe there's a simple fix but cannot debug it out.



I have file called "file name with space"
How do I cat this file from Linux bash ?







linux bash cat






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 12 '13 at 18:21









MaulzeyMaulzey

138117




138117




migrated from stackoverflow.com Jun 12 '13 at 20:14


This question came from our site for professional and enthusiast programmers.









migrated from stackoverflow.com Jun 12 '13 at 20:14


This question came from our site for professional and enthusiast programmers.










  • 2





    cat "file name with space" or cat file name with space

    – ctn
    Jun 12 '13 at 18:22






  • 2





    cat "file with space" doesn't work!? Good luck.

    – shellter
    Jun 12 '13 at 18:22











  • Sure: name your file file_name_with_underscore...

    – H2CO3
    Jun 12 '13 at 18:27











  • @H2CO3 Why if it works if everythin is implemented well?

    – glglgl
    Jun 12 '13 at 18:34











  • @glglgl Safe, convenient, cross-platform and idiomatic.

    – H2CO3
    Jun 12 '13 at 18:35














  • 2





    cat "file name with space" or cat file name with space

    – ctn
    Jun 12 '13 at 18:22






  • 2





    cat "file with space" doesn't work!? Good luck.

    – shellter
    Jun 12 '13 at 18:22











  • Sure: name your file file_name_with_underscore...

    – H2CO3
    Jun 12 '13 at 18:27











  • @H2CO3 Why if it works if everythin is implemented well?

    – glglgl
    Jun 12 '13 at 18:34











  • @glglgl Safe, convenient, cross-platform and idiomatic.

    – H2CO3
    Jun 12 '13 at 18:35








2




2





cat "file name with space" or cat file name with space

– ctn
Jun 12 '13 at 18:22





cat "file name with space" or cat file name with space

– ctn
Jun 12 '13 at 18:22




2




2





cat "file with space" doesn't work!? Good luck.

– shellter
Jun 12 '13 at 18:22





cat "file with space" doesn't work!? Good luck.

– shellter
Jun 12 '13 at 18:22













Sure: name your file file_name_with_underscore...

– H2CO3
Jun 12 '13 at 18:27





Sure: name your file file_name_with_underscore...

– H2CO3
Jun 12 '13 at 18:27













@H2CO3 Why if it works if everythin is implemented well?

– glglgl
Jun 12 '13 at 18:34





@H2CO3 Why if it works if everythin is implemented well?

– glglgl
Jun 12 '13 at 18:34













@glglgl Safe, convenient, cross-platform and idiomatic.

– H2CO3
Jun 12 '13 at 18:35





@glglgl Safe, convenient, cross-platform and idiomatic.

– H2CO3
Jun 12 '13 at 18:35










5 Answers
5






active

oldest

votes


















7














Does putting quotation marks around the name not work?



cat "file name with space"





share|improve this answer































    6














    A third option would be



    cat 'file name with space'


    where the file name may contain everything but the '.



    If it does, such as file n'ame, replace every ' with ''':



    cat 'file n'''ame'





    share|improve this answer































      5














      Use the escape character '' like this



      cat file name with space





      share|improve this answer































        2














        Enclosing the file in double quotes should work i.e.



        cat "file name with space" 





        share|improve this answer































          -2














          I have run into this problem on Linux and in Cygwin. The one thing I found that works is to enclose the name in double-quotes and to replace non-traditional characters with asterisks. For example:




          tail File.basename.Job With Spaces.log




          becomes...




          tail "File.basename.Job*With*Spaces.log"




          I tried escaping the spaces with backslashes, whether unprotected, protected with double-quotes, or protected with single-quotes, and in all cases tail parsed the names at the spaces as though unprotected.






          share|improve this answer



















          • 1





            This is WRONG.  Three (slightly) different perfectly good (correct) answers have already been given; if you have a problem with them, try again (and make sure you do what they say).  But your answer will not work!!

            – Scott
            Feb 16 '17 at 22:26











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          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
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f606874%2fcannot-cat-file-which-has-space-in-name-in-linux%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          5 Answers
          5






          active

          oldest

          votes








          5 Answers
          5






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          7














          Does putting quotation marks around the name not work?



          cat "file name with space"





          share|improve this answer




























            7














            Does putting quotation marks around the name not work?



            cat "file name with space"





            share|improve this answer


























              7












              7








              7







              Does putting quotation marks around the name not work?



              cat "file name with space"





              share|improve this answer













              Does putting quotation marks around the name not work?



              cat "file name with space"






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Jun 12 '13 at 18:23









              Phil PerryPhil Perry

              21916




              21916

























                  6














                  A third option would be



                  cat 'file name with space'


                  where the file name may contain everything but the '.



                  If it does, such as file n'ame, replace every ' with ''':



                  cat 'file n'''ame'





                  share|improve this answer




























                    6














                    A third option would be



                    cat 'file name with space'


                    where the file name may contain everything but the '.



                    If it does, such as file n'ame, replace every ' with ''':



                    cat 'file n'''ame'





                    share|improve this answer


























                      6












                      6








                      6







                      A third option would be



                      cat 'file name with space'


                      where the file name may contain everything but the '.



                      If it does, such as file n'ame, replace every ' with ''':



                      cat 'file n'''ame'





                      share|improve this answer













                      A third option would be



                      cat 'file name with space'


                      where the file name may contain everything but the '.



                      If it does, such as file n'ame, replace every ' with ''':



                      cat 'file n'''ame'






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Jun 12 '13 at 18:36









                      glglglglglgl

                      1,285822




                      1,285822























                          5














                          Use the escape character '' like this



                          cat file name with space





                          share|improve this answer




























                            5














                            Use the escape character '' like this



                            cat file name with space





                            share|improve this answer


























                              5












                              5








                              5







                              Use the escape character '' like this



                              cat file name with space





                              share|improve this answer













                              Use the escape character '' like this



                              cat file name with space






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Jun 12 '13 at 18:25









                              scarecrowscarecrow

                              1546




                              1546























                                  2














                                  Enclosing the file in double quotes should work i.e.



                                  cat "file name with space" 





                                  share|improve this answer




























                                    2














                                    Enclosing the file in double quotes should work i.e.



                                    cat "file name with space" 





                                    share|improve this answer


























                                      2












                                      2








                                      2







                                      Enclosing the file in double quotes should work i.e.



                                      cat "file name with space" 





                                      share|improve this answer













                                      Enclosing the file in double quotes should work i.e.



                                      cat "file name with space" 






                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Jun 12 '13 at 18:23







                                      Afsal






























                                          -2














                                          I have run into this problem on Linux and in Cygwin. The one thing I found that works is to enclose the name in double-quotes and to replace non-traditional characters with asterisks. For example:




                                          tail File.basename.Job With Spaces.log




                                          becomes...




                                          tail "File.basename.Job*With*Spaces.log"




                                          I tried escaping the spaces with backslashes, whether unprotected, protected with double-quotes, or protected with single-quotes, and in all cases tail parsed the names at the spaces as though unprotected.






                                          share|improve this answer



















                                          • 1





                                            This is WRONG.  Three (slightly) different perfectly good (correct) answers have already been given; if you have a problem with them, try again (and make sure you do what they say).  But your answer will not work!!

                                            – Scott
                                            Feb 16 '17 at 22:26
















                                          -2














                                          I have run into this problem on Linux and in Cygwin. The one thing I found that works is to enclose the name in double-quotes and to replace non-traditional characters with asterisks. For example:




                                          tail File.basename.Job With Spaces.log




                                          becomes...




                                          tail "File.basename.Job*With*Spaces.log"




                                          I tried escaping the spaces with backslashes, whether unprotected, protected with double-quotes, or protected with single-quotes, and in all cases tail parsed the names at the spaces as though unprotected.






                                          share|improve this answer



















                                          • 1





                                            This is WRONG.  Three (slightly) different perfectly good (correct) answers have already been given; if you have a problem with them, try again (and make sure you do what they say).  But your answer will not work!!

                                            – Scott
                                            Feb 16 '17 at 22:26














                                          -2












                                          -2








                                          -2







                                          I have run into this problem on Linux and in Cygwin. The one thing I found that works is to enclose the name in double-quotes and to replace non-traditional characters with asterisks. For example:




                                          tail File.basename.Job With Spaces.log




                                          becomes...




                                          tail "File.basename.Job*With*Spaces.log"




                                          I tried escaping the spaces with backslashes, whether unprotected, protected with double-quotes, or protected with single-quotes, and in all cases tail parsed the names at the spaces as though unprotected.






                                          share|improve this answer













                                          I have run into this problem on Linux and in Cygwin. The one thing I found that works is to enclose the name in double-quotes and to replace non-traditional characters with asterisks. For example:




                                          tail File.basename.Job With Spaces.log




                                          becomes...




                                          tail "File.basename.Job*With*Spaces.log"




                                          I tried escaping the spaces with backslashes, whether unprotected, protected with double-quotes, or protected with single-quotes, and in all cases tail parsed the names at the spaces as though unprotected.







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Feb 16 '17 at 20:52









                                          Scot HarkinsScot Harkins

                                          11




                                          11








                                          • 1





                                            This is WRONG.  Three (slightly) different perfectly good (correct) answers have already been given; if you have a problem with them, try again (and make sure you do what they say).  But your answer will not work!!

                                            – Scott
                                            Feb 16 '17 at 22:26














                                          • 1





                                            This is WRONG.  Three (slightly) different perfectly good (correct) answers have already been given; if you have a problem with them, try again (and make sure you do what they say).  But your answer will not work!!

                                            – Scott
                                            Feb 16 '17 at 22:26








                                          1




                                          1





                                          This is WRONG.  Three (slightly) different perfectly good (correct) answers have already been given; if you have a problem with them, try again (and make sure you do what they say).  But your answer will not work!!

                                          – Scott
                                          Feb 16 '17 at 22:26





                                          This is WRONG.  Three (slightly) different perfectly good (correct) answers have already been given; if you have a problem with them, try again (and make sure you do what they say).  But your answer will not work!!

                                          – Scott
                                          Feb 16 '17 at 22:26


















                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to Super User!


                                          • 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%2fsuperuser.com%2fquestions%2f606874%2fcannot-cat-file-which-has-space-in-name-in-linux%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

                                          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                                          Alcedinidae

                                          Origin of the phrase “under your belt”?