Is such redirection “|>” just an error or it means something?

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











up vote
1
down vote

favorite












I typed it by mistake but bash didn't print any errors (but created an empty file) so I thought maybe it actually means something ?
(e.g. date |> tmp.txt)










share|improve this question

























    up vote
    1
    down vote

    favorite












    I typed it by mistake but bash didn't print any errors (but created an empty file) so I thought maybe it actually means something ?
    (e.g. date |> tmp.txt)










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I typed it by mistake but bash didn't print any errors (but created an empty file) so I thought maybe it actually means something ?
      (e.g. date |> tmp.txt)










      share|improve this question













      I typed it by mistake but bash didn't print any errors (but created an empty file) so I thought maybe it actually means something ?
      (e.g. date |> tmp.txt)







      bash io-redirection






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 1 hour ago









      Bdimych2 Bdimych2

      111




      111




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          4
          down vote













          That seems to be just a pipeline where the second part is an empty command, only containing the redirection. Writing it as date | >file might make it more easy to interpret. The empty command doesn't do anything but process the redirection, creating the file.



          date >| file on the other hand would act as an override for the noclobber shell option, which prevents the regular > from overwriting existing files.



          $ touch foo; set -o noclobber
          $ date > foo
          bash: foo: cannot overwrite existing file
          $ date >| foo # works





          share|improve this answer



























            up vote
            0
            down vote













            Yes, it will not throw error because for bash > file means redirect to a file named file. As in your case there is nothing to redirect to file, bash will just create a file name file with nothing in it.



            [bd@centos-6.5 my-tests]$ date | > my_file
            [bd@centos-6.5 my-tests]$ cat my_file
            [bd@centos-6.5 my-tests]$





            share|improve this answer






















            • Funny. Zsh has a different behavior: after the command, my_file contains the output of date.
              – Najib Idrissi
              27 secs ago










            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%2f471258%2fis-such-redirection-just-an-error-or-it-means-something%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            4
            down vote













            That seems to be just a pipeline where the second part is an empty command, only containing the redirection. Writing it as date | >file might make it more easy to interpret. The empty command doesn't do anything but process the redirection, creating the file.



            date >| file on the other hand would act as an override for the noclobber shell option, which prevents the regular > from overwriting existing files.



            $ touch foo; set -o noclobber
            $ date > foo
            bash: foo: cannot overwrite existing file
            $ date >| foo # works





            share|improve this answer
























              up vote
              4
              down vote













              That seems to be just a pipeline where the second part is an empty command, only containing the redirection. Writing it as date | >file might make it more easy to interpret. The empty command doesn't do anything but process the redirection, creating the file.



              date >| file on the other hand would act as an override for the noclobber shell option, which prevents the regular > from overwriting existing files.



              $ touch foo; set -o noclobber
              $ date > foo
              bash: foo: cannot overwrite existing file
              $ date >| foo # works





              share|improve this answer






















                up vote
                4
                down vote










                up vote
                4
                down vote









                That seems to be just a pipeline where the second part is an empty command, only containing the redirection. Writing it as date | >file might make it more easy to interpret. The empty command doesn't do anything but process the redirection, creating the file.



                date >| file on the other hand would act as an override for the noclobber shell option, which prevents the regular > from overwriting existing files.



                $ touch foo; set -o noclobber
                $ date > foo
                bash: foo: cannot overwrite existing file
                $ date >| foo # works





                share|improve this answer












                That seems to be just a pipeline where the second part is an empty command, only containing the redirection. Writing it as date | >file might make it more easy to interpret. The empty command doesn't do anything but process the redirection, creating the file.



                date >| file on the other hand would act as an override for the noclobber shell option, which prevents the regular > from overwriting existing files.



                $ touch foo; set -o noclobber
                $ date > foo
                bash: foo: cannot overwrite existing file
                $ date >| foo # works






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 1 hour ago









                ilkkachu

                51.4k678141




                51.4k678141






















                    up vote
                    0
                    down vote













                    Yes, it will not throw error because for bash > file means redirect to a file named file. As in your case there is nothing to redirect to file, bash will just create a file name file with nothing in it.



                    [bd@centos-6.5 my-tests]$ date | > my_file
                    [bd@centos-6.5 my-tests]$ cat my_file
                    [bd@centos-6.5 my-tests]$





                    share|improve this answer






















                    • Funny. Zsh has a different behavior: after the command, my_file contains the output of date.
                      – Najib Idrissi
                      27 secs ago














                    up vote
                    0
                    down vote













                    Yes, it will not throw error because for bash > file means redirect to a file named file. As in your case there is nothing to redirect to file, bash will just create a file name file with nothing in it.



                    [bd@centos-6.5 my-tests]$ date | > my_file
                    [bd@centos-6.5 my-tests]$ cat my_file
                    [bd@centos-6.5 my-tests]$





                    share|improve this answer






















                    • Funny. Zsh has a different behavior: after the command, my_file contains the output of date.
                      – Najib Idrissi
                      27 secs ago












                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    Yes, it will not throw error because for bash > file means redirect to a file named file. As in your case there is nothing to redirect to file, bash will just create a file name file with nothing in it.



                    [bd@centos-6.5 my-tests]$ date | > my_file
                    [bd@centos-6.5 my-tests]$ cat my_file
                    [bd@centos-6.5 my-tests]$





                    share|improve this answer














                    Yes, it will not throw error because for bash > file means redirect to a file named file. As in your case there is nothing to redirect to file, bash will just create a file name file with nothing in it.



                    [bd@centos-6.5 my-tests]$ date | > my_file
                    [bd@centos-6.5 my-tests]$ cat my_file
                    [bd@centos-6.5 my-tests]$






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 13 mins ago

























                    answered 20 mins ago









                    Bhagyesh Dudhediya

                    306314




                    306314











                    • Funny. Zsh has a different behavior: after the command, my_file contains the output of date.
                      – Najib Idrissi
                      27 secs ago
















                    • Funny. Zsh has a different behavior: after the command, my_file contains the output of date.
                      – Najib Idrissi
                      27 secs ago















                    Funny. Zsh has a different behavior: after the command, my_file contains the output of date.
                    – Najib Idrissi
                    27 secs ago




                    Funny. Zsh has a different behavior: after the command, my_file contains the output of date.
                    – Najib Idrissi
                    27 secs ago

















                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f471258%2fis-such-redirection-just-an-error-or-it-means-something%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    Confectionery