Why does ''cat "$1:-/dev/stdin | … &>/dev/null'' work in bash but not dash?Why does redirection (>) not work sometimes but appending (>>) does?Why does the less-than sign not work as a replacement for cat in bash?How does `cat <> file` work?How to use namedpipe as temporary file?Why does dash expand \\ differently to bash?What is the difference between “cat file | ./binary” and “./binary < file”?Why might >/dev/null 2>&1 not work?Bash tcp redirection end of transmissionWhy bash “read -t 0” does not see input?How shell delivers user's input to program and shows program's output?

Why is Skinner so awkward in Hot Fuzz?

In The Incredibles 2, why does Screenslaver's name use a pun on something that doesn't exist in the 1950s pastiche?

Does WiFi affect the quality of images downloaded from the internet?

Approach sick days in feedback meeting

Must a CPU have a GPU if the motherboard provides a display port (when there isn't any separate video card)?

Boss making me feel guilty for leaving the company at the end of my internship

I received a gift from my sister who just got back from

Can I get a photo of an Ancient Arrow?

What does this circuit symbol mean?

Dedicated bike GPS computer over smartphone

What is the theme of analysis?

Why is C++ template use not recommended in space/radiated environment?

Am I being scammed by a sugar daddy?

Opposite of "Concerto Grosso"?

How to search for Android apps without ads?

Why can't we feel the Earth's revolution?

What happens when one target of Paradoxical Outcome becomes illegal?

Is it ethical to cite a reviewer's papers even if they are rather irrelevant?

Can an open source licence be revoked if it violates employer's IP?

Integrate without expansion?

Realistic, logical way for men with medieval-era weaponry to compete with much larger and physically stronger foes

Parsing text written the millitext font

My players want to use called-shots on Strahd

Placement of positioning lights on A320 winglets



Why does ''cat "$1:-/dev/stdin | … &>/dev/null'' work in bash but not dash?


Why does redirection (>) not work sometimes but appending (>>) does?Why does the less-than sign not work as a replacement for cat in bash?How does `cat <> file` work?How to use namedpipe as temporary file?Why does dash expand \\ differently to bash?What is the difference between “cat file | ./binary” and “./binary < file”?Why might >/dev/null 2>&1 not work?Bash tcp redirection end of transmissionWhy bash “read -t 0” does not see input?How shell delivers user's input to program and shows program's output?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















Script:



#!/bin/sh
#
# reads stdin/file and copies it to clipboard
# clears it after 30s
#
cat "$1:-/dev/stdin" | timeout 30 xclip -i -selection clipboard -r -verbose &>/dev/null &


I can see that only stdin does not work (with bash it works on stdin/file).

P.S. verbose is used to make xclip not daemonize.










share|improve this question









New contributor



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



















  • That won't work with /dev/stdin even with bash. Since you're running with the pipeline put in the background (terminated with &) cat /dev/stdin will either have its stdin redirected from /dev/null (when running in a script) or will be stopped by a SIGTTIN signal (when running in an interactive shell).

    – mosvy
    Jun 6 at 22:39











  • you sure about the second? because it works (bash) in my terminal echo 123 | script. Is there anyway I can do what I want to do?

    – droso
    Jun 6 at 22:49











  • Look at end of the pipeline in your Q. There's a & at the end -- the shell won't treat it as decoration ;-)

    – mosvy
    Jun 6 at 22:51











  • of course not but whole script will work in the foreground (because of -verbose but -verbose is needed to make timeout work)

    – droso
    Jun 6 at 22:58












  • Try this in your script: exec 3<"$1:-/dev/stdin"; cat <&3 | ... &.

    – mosvy
    Jun 6 at 22:59


















4















Script:



#!/bin/sh
#
# reads stdin/file and copies it to clipboard
# clears it after 30s
#
cat "$1:-/dev/stdin" | timeout 30 xclip -i -selection clipboard -r -verbose &>/dev/null &


I can see that only stdin does not work (with bash it works on stdin/file).

P.S. verbose is used to make xclip not daemonize.










share|improve this question









New contributor



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



















  • That won't work with /dev/stdin even with bash. Since you're running with the pipeline put in the background (terminated with &) cat /dev/stdin will either have its stdin redirected from /dev/null (when running in a script) or will be stopped by a SIGTTIN signal (when running in an interactive shell).

    – mosvy
    Jun 6 at 22:39











  • you sure about the second? because it works (bash) in my terminal echo 123 | script. Is there anyway I can do what I want to do?

    – droso
    Jun 6 at 22:49











  • Look at end of the pipeline in your Q. There's a & at the end -- the shell won't treat it as decoration ;-)

    – mosvy
    Jun 6 at 22:51











  • of course not but whole script will work in the foreground (because of -verbose but -verbose is needed to make timeout work)

    – droso
    Jun 6 at 22:58












  • Try this in your script: exec 3<"$1:-/dev/stdin"; cat <&3 | ... &.

    – mosvy
    Jun 6 at 22:59














4












4








4








Script:



#!/bin/sh
#
# reads stdin/file and copies it to clipboard
# clears it after 30s
#
cat "$1:-/dev/stdin" | timeout 30 xclip -i -selection clipboard -r -verbose &>/dev/null &


I can see that only stdin does not work (with bash it works on stdin/file).

P.S. verbose is used to make xclip not daemonize.










share|improve this question









New contributor



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











Script:



#!/bin/sh
#
# reads stdin/file and copies it to clipboard
# clears it after 30s
#
cat "$1:-/dev/stdin" | timeout 30 xclip -i -selection clipboard -r -verbose &>/dev/null &


I can see that only stdin does not work (with bash it works on stdin/file).

P.S. verbose is used to make xclip not daemonize.







bash shell pipe io-redirection dash






share|improve this question









New contributor



droso 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



droso 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 Jun 7 at 20:38









Charles Duffy

852615




852615






New contributor



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








asked Jun 6 at 22:10









drosodroso

267




267




New contributor



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




New contributor




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














  • That won't work with /dev/stdin even with bash. Since you're running with the pipeline put in the background (terminated with &) cat /dev/stdin will either have its stdin redirected from /dev/null (when running in a script) or will be stopped by a SIGTTIN signal (when running in an interactive shell).

    – mosvy
    Jun 6 at 22:39











  • you sure about the second? because it works (bash) in my terminal echo 123 | script. Is there anyway I can do what I want to do?

    – droso
    Jun 6 at 22:49











  • Look at end of the pipeline in your Q. There's a & at the end -- the shell won't treat it as decoration ;-)

    – mosvy
    Jun 6 at 22:51











  • of course not but whole script will work in the foreground (because of -verbose but -verbose is needed to make timeout work)

    – droso
    Jun 6 at 22:58












  • Try this in your script: exec 3<"$1:-/dev/stdin"; cat <&3 | ... &.

    – mosvy
    Jun 6 at 22:59


















  • That won't work with /dev/stdin even with bash. Since you're running with the pipeline put in the background (terminated with &) cat /dev/stdin will either have its stdin redirected from /dev/null (when running in a script) or will be stopped by a SIGTTIN signal (when running in an interactive shell).

    – mosvy
    Jun 6 at 22:39











  • you sure about the second? because it works (bash) in my terminal echo 123 | script. Is there anyway I can do what I want to do?

    – droso
    Jun 6 at 22:49











  • Look at end of the pipeline in your Q. There's a & at the end -- the shell won't treat it as decoration ;-)

    – mosvy
    Jun 6 at 22:51











  • of course not but whole script will work in the foreground (because of -verbose but -verbose is needed to make timeout work)

    – droso
    Jun 6 at 22:58












  • Try this in your script: exec 3<"$1:-/dev/stdin"; cat <&3 | ... &.

    – mosvy
    Jun 6 at 22:59

















That won't work with /dev/stdin even with bash. Since you're running with the pipeline put in the background (terminated with &) cat /dev/stdin will either have its stdin redirected from /dev/null (when running in a script) or will be stopped by a SIGTTIN signal (when running in an interactive shell).

– mosvy
Jun 6 at 22:39





That won't work with /dev/stdin even with bash. Since you're running with the pipeline put in the background (terminated with &) cat /dev/stdin will either have its stdin redirected from /dev/null (when running in a script) or will be stopped by a SIGTTIN signal (when running in an interactive shell).

– mosvy
Jun 6 at 22:39













you sure about the second? because it works (bash) in my terminal echo 123 | script. Is there anyway I can do what I want to do?

– droso
Jun 6 at 22:49





you sure about the second? because it works (bash) in my terminal echo 123 | script. Is there anyway I can do what I want to do?

– droso
Jun 6 at 22:49













Look at end of the pipeline in your Q. There's a & at the end -- the shell won't treat it as decoration ;-)

– mosvy
Jun 6 at 22:51





Look at end of the pipeline in your Q. There's a & at the end -- the shell won't treat it as decoration ;-)

– mosvy
Jun 6 at 22:51













of course not but whole script will work in the foreground (because of -verbose but -verbose is needed to make timeout work)

– droso
Jun 6 at 22:58






of course not but whole script will work in the foreground (because of -verbose but -verbose is needed to make timeout work)

– droso
Jun 6 at 22:58














Try this in your script: exec 3<"$1:-/dev/stdin"; cat <&3 | ... &.

– mosvy
Jun 6 at 22:59






Try this in your script: exec 3<"$1:-/dev/stdin"; cat <&3 | ... &.

– mosvy
Jun 6 at 22:59











3 Answers
3






active

oldest

votes


















4














[this answer is about asynchronous pipelines in scripts; for the deprecated &> bash operator and why you should always use >output 2>&1 instead, refer to obsolete and deprecated syntax]




#! /bin/sh
cat "$1:-/dev/stdin" | ... &



Here you have a pipeline running asynchronously (because terminated by &), started from a script, ie is from a shell with the job control disabled.



According to the standard:




command1 & [command2 & ... ]



The standard input for an asynchronous list, before any explicit
redirections are performed, shall be considered to be assigned to a file that has the same properties as /dev/null.




The problem is that dash, ksh, mksh, yash, etc intepret "asynchronous list" as any command, including a pipeline, and will redirect the stdin of the first command from /dev/null:



$ echo foo | dash -c 'cat | tr fo FO & echo DONE'
DONE
$ echo | dash -c 'readlink /proc/self/fd/0 | cat & echo DONE'
DONE
/dev/null


But bash will only interpret it as "simple command" and will only redirect its stdin from /dev/null when it's not part of a pipeline:



$ echo foo | bash -c 'cat | tr fo FO & echo DONE'
DONE
FOO
$ echo | bash -c 'readlink /proc/self/fd/0 | cat & echo DONE'
DONE
pipe:[69872]
$ echo | bash -c 'readlink /proc/self/fd/0 & echo DONE'
DONE
/dev/null
$ bash -c 'cat | tr a A & echo DONE'
DONE
cat: -: Input/output error


zsh will only redirect it from /dev/null when the original stdin is a tty, not when it's other kind of file:



$ zsh -c 'readlink /proc/self/fd/0 &' </dev/tty
/dev/null
$ zsh -c 'readlink /proc/self/fd/0 &' </dev/zero
/dev/zero



A workaround which works in all shells is to duplicate the stdin into another file descriptor, and redirect the stdin of the first command from it:



#! /bin/sh
exec 3<"$1:-/dev/stdin"
cat <&3 | timeout 30 xclip -i -selection clipboard -verbose -r >/dev/null 2>&1 &





share|improve this answer
































    10














    &> is a bashism, you will have to change it to >/dev/null 2>&1 for POSIX shells






    share|improve this answer




















    • 1





      Now stdout is suppressed like it should be thank you BUT stdin is still not working ($1 works). Also I had to use >/dev/null 2>&1

      – droso
      Jun 6 at 22:22



















    7














    dash positioned as POSIX standard. POSIX specified only [n]> redirection. But bash introduces many own features. &> is one of them and means output descriptors (stderr and stdout).



    You should read article about bash and dash compatibility.



    Maybe you get helpful checkbashisms utility which can helps to find bash-specific instructions in your scripts.






    share|improve this answer




















    • 1





      &> is only stdout and stderr, not "all" file descriptors. (It's also considered obsolescent and not suggested for use, even in bash).

      – Charles Duffy
      Jun 7 at 18:58












    • @CharlesDuffy Thank's for correction. I've just fixed it in the own answer!

      – Yurij Goncharuk
      Jun 7 at 20:31











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



    );






    droso 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%2f523421%2fwhy-does-cat-1-dev-stdin-dev-null-work-in-bash-but-not-dash%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    [this answer is about asynchronous pipelines in scripts; for the deprecated &> bash operator and why you should always use >output 2>&1 instead, refer to obsolete and deprecated syntax]




    #! /bin/sh
    cat "$1:-/dev/stdin" | ... &



    Here you have a pipeline running asynchronously (because terminated by &), started from a script, ie is from a shell with the job control disabled.



    According to the standard:




    command1 & [command2 & ... ]



    The standard input for an asynchronous list, before any explicit
    redirections are performed, shall be considered to be assigned to a file that has the same properties as /dev/null.




    The problem is that dash, ksh, mksh, yash, etc intepret "asynchronous list" as any command, including a pipeline, and will redirect the stdin of the first command from /dev/null:



    $ echo foo | dash -c 'cat | tr fo FO & echo DONE'
    DONE
    $ echo | dash -c 'readlink /proc/self/fd/0 | cat & echo DONE'
    DONE
    /dev/null


    But bash will only interpret it as "simple command" and will only redirect its stdin from /dev/null when it's not part of a pipeline:



    $ echo foo | bash -c 'cat | tr fo FO & echo DONE'
    DONE
    FOO
    $ echo | bash -c 'readlink /proc/self/fd/0 | cat & echo DONE'
    DONE
    pipe:[69872]
    $ echo | bash -c 'readlink /proc/self/fd/0 & echo DONE'
    DONE
    /dev/null
    $ bash -c 'cat | tr a A & echo DONE'
    DONE
    cat: -: Input/output error


    zsh will only redirect it from /dev/null when the original stdin is a tty, not when it's other kind of file:



    $ zsh -c 'readlink /proc/self/fd/0 &' </dev/tty
    /dev/null
    $ zsh -c 'readlink /proc/self/fd/0 &' </dev/zero
    /dev/zero



    A workaround which works in all shells is to duplicate the stdin into another file descriptor, and redirect the stdin of the first command from it:



    #! /bin/sh
    exec 3<"$1:-/dev/stdin"
    cat <&3 | timeout 30 xclip -i -selection clipboard -verbose -r >/dev/null 2>&1 &





    share|improve this answer





























      4














      [this answer is about asynchronous pipelines in scripts; for the deprecated &> bash operator and why you should always use >output 2>&1 instead, refer to obsolete and deprecated syntax]




      #! /bin/sh
      cat "$1:-/dev/stdin" | ... &



      Here you have a pipeline running asynchronously (because terminated by &), started from a script, ie is from a shell with the job control disabled.



      According to the standard:




      command1 & [command2 & ... ]



      The standard input for an asynchronous list, before any explicit
      redirections are performed, shall be considered to be assigned to a file that has the same properties as /dev/null.




      The problem is that dash, ksh, mksh, yash, etc intepret "asynchronous list" as any command, including a pipeline, and will redirect the stdin of the first command from /dev/null:



      $ echo foo | dash -c 'cat | tr fo FO & echo DONE'
      DONE
      $ echo | dash -c 'readlink /proc/self/fd/0 | cat & echo DONE'
      DONE
      /dev/null


      But bash will only interpret it as "simple command" and will only redirect its stdin from /dev/null when it's not part of a pipeline:



      $ echo foo | bash -c 'cat | tr fo FO & echo DONE'
      DONE
      FOO
      $ echo | bash -c 'readlink /proc/self/fd/0 | cat & echo DONE'
      DONE
      pipe:[69872]
      $ echo | bash -c 'readlink /proc/self/fd/0 & echo DONE'
      DONE
      /dev/null
      $ bash -c 'cat | tr a A & echo DONE'
      DONE
      cat: -: Input/output error


      zsh will only redirect it from /dev/null when the original stdin is a tty, not when it's other kind of file:



      $ zsh -c 'readlink /proc/self/fd/0 &' </dev/tty
      /dev/null
      $ zsh -c 'readlink /proc/self/fd/0 &' </dev/zero
      /dev/zero



      A workaround which works in all shells is to duplicate the stdin into another file descriptor, and redirect the stdin of the first command from it:



      #! /bin/sh
      exec 3<"$1:-/dev/stdin"
      cat <&3 | timeout 30 xclip -i -selection clipboard -verbose -r >/dev/null 2>&1 &





      share|improve this answer



























        4












        4








        4







        [this answer is about asynchronous pipelines in scripts; for the deprecated &> bash operator and why you should always use >output 2>&1 instead, refer to obsolete and deprecated syntax]




        #! /bin/sh
        cat "$1:-/dev/stdin" | ... &



        Here you have a pipeline running asynchronously (because terminated by &), started from a script, ie is from a shell with the job control disabled.



        According to the standard:




        command1 & [command2 & ... ]



        The standard input for an asynchronous list, before any explicit
        redirections are performed, shall be considered to be assigned to a file that has the same properties as /dev/null.




        The problem is that dash, ksh, mksh, yash, etc intepret "asynchronous list" as any command, including a pipeline, and will redirect the stdin of the first command from /dev/null:



        $ echo foo | dash -c 'cat | tr fo FO & echo DONE'
        DONE
        $ echo | dash -c 'readlink /proc/self/fd/0 | cat & echo DONE'
        DONE
        /dev/null


        But bash will only interpret it as "simple command" and will only redirect its stdin from /dev/null when it's not part of a pipeline:



        $ echo foo | bash -c 'cat | tr fo FO & echo DONE'
        DONE
        FOO
        $ echo | bash -c 'readlink /proc/self/fd/0 | cat & echo DONE'
        DONE
        pipe:[69872]
        $ echo | bash -c 'readlink /proc/self/fd/0 & echo DONE'
        DONE
        /dev/null
        $ bash -c 'cat | tr a A & echo DONE'
        DONE
        cat: -: Input/output error


        zsh will only redirect it from /dev/null when the original stdin is a tty, not when it's other kind of file:



        $ zsh -c 'readlink /proc/self/fd/0 &' </dev/tty
        /dev/null
        $ zsh -c 'readlink /proc/self/fd/0 &' </dev/zero
        /dev/zero



        A workaround which works in all shells is to duplicate the stdin into another file descriptor, and redirect the stdin of the first command from it:



        #! /bin/sh
        exec 3<"$1:-/dev/stdin"
        cat <&3 | timeout 30 xclip -i -selection clipboard -verbose -r >/dev/null 2>&1 &





        share|improve this answer















        [this answer is about asynchronous pipelines in scripts; for the deprecated &> bash operator and why you should always use >output 2>&1 instead, refer to obsolete and deprecated syntax]




        #! /bin/sh
        cat "$1:-/dev/stdin" | ... &



        Here you have a pipeline running asynchronously (because terminated by &), started from a script, ie is from a shell with the job control disabled.



        According to the standard:




        command1 & [command2 & ... ]



        The standard input for an asynchronous list, before any explicit
        redirections are performed, shall be considered to be assigned to a file that has the same properties as /dev/null.




        The problem is that dash, ksh, mksh, yash, etc intepret "asynchronous list" as any command, including a pipeline, and will redirect the stdin of the first command from /dev/null:



        $ echo foo | dash -c 'cat | tr fo FO & echo DONE'
        DONE
        $ echo | dash -c 'readlink /proc/self/fd/0 | cat & echo DONE'
        DONE
        /dev/null


        But bash will only interpret it as "simple command" and will only redirect its stdin from /dev/null when it's not part of a pipeline:



        $ echo foo | bash -c 'cat | tr fo FO & echo DONE'
        DONE
        FOO
        $ echo | bash -c 'readlink /proc/self/fd/0 | cat & echo DONE'
        DONE
        pipe:[69872]
        $ echo | bash -c 'readlink /proc/self/fd/0 & echo DONE'
        DONE
        /dev/null
        $ bash -c 'cat | tr a A & echo DONE'
        DONE
        cat: -: Input/output error


        zsh will only redirect it from /dev/null when the original stdin is a tty, not when it's other kind of file:



        $ zsh -c 'readlink /proc/self/fd/0 &' </dev/tty
        /dev/null
        $ zsh -c 'readlink /proc/self/fd/0 &' </dev/zero
        /dev/zero



        A workaround which works in all shells is to duplicate the stdin into another file descriptor, and redirect the stdin of the first command from it:



        #! /bin/sh
        exec 3<"$1:-/dev/stdin"
        cat <&3 | timeout 30 xclip -i -selection clipboard -verbose -r >/dev/null 2>&1 &






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jun 7 at 18:59









        Jeff Schaller

        46.5k1167152




        46.5k1167152










        answered Jun 7 at 10:42









        mosvymosvy

        13.4k21545




        13.4k21545























            10














            &> is a bashism, you will have to change it to >/dev/null 2>&1 for POSIX shells






            share|improve this answer




















            • 1





              Now stdout is suppressed like it should be thank you BUT stdin is still not working ($1 works). Also I had to use >/dev/null 2>&1

              – droso
              Jun 6 at 22:22
















            10














            &> is a bashism, you will have to change it to >/dev/null 2>&1 for POSIX shells






            share|improve this answer




















            • 1





              Now stdout is suppressed like it should be thank you BUT stdin is still not working ($1 works). Also I had to use >/dev/null 2>&1

              – droso
              Jun 6 at 22:22














            10












            10








            10







            &> is a bashism, you will have to change it to >/dev/null 2>&1 for POSIX shells






            share|improve this answer















            &> is a bashism, you will have to change it to >/dev/null 2>&1 for POSIX shells







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jun 7 at 19:11









            Michael Mior

            22528




            22528










            answered Jun 6 at 22:13









            Jesse_bJesse_b

            16.5k34080




            16.5k34080







            • 1





              Now stdout is suppressed like it should be thank you BUT stdin is still not working ($1 works). Also I had to use >/dev/null 2>&1

              – droso
              Jun 6 at 22:22













            • 1





              Now stdout is suppressed like it should be thank you BUT stdin is still not working ($1 works). Also I had to use >/dev/null 2>&1

              – droso
              Jun 6 at 22:22








            1




            1





            Now stdout is suppressed like it should be thank you BUT stdin is still not working ($1 works). Also I had to use >/dev/null 2>&1

            – droso
            Jun 6 at 22:22






            Now stdout is suppressed like it should be thank you BUT stdin is still not working ($1 works). Also I had to use >/dev/null 2>&1

            – droso
            Jun 6 at 22:22












            7














            dash positioned as POSIX standard. POSIX specified only [n]> redirection. But bash introduces many own features. &> is one of them and means output descriptors (stderr and stdout).



            You should read article about bash and dash compatibility.



            Maybe you get helpful checkbashisms utility which can helps to find bash-specific instructions in your scripts.






            share|improve this answer




















            • 1





              &> is only stdout and stderr, not "all" file descriptors. (It's also considered obsolescent and not suggested for use, even in bash).

              – Charles Duffy
              Jun 7 at 18:58












            • @CharlesDuffy Thank's for correction. I've just fixed it in the own answer!

              – Yurij Goncharuk
              Jun 7 at 20:31















            7














            dash positioned as POSIX standard. POSIX specified only [n]> redirection. But bash introduces many own features. &> is one of them and means output descriptors (stderr and stdout).



            You should read article about bash and dash compatibility.



            Maybe you get helpful checkbashisms utility which can helps to find bash-specific instructions in your scripts.






            share|improve this answer




















            • 1





              &> is only stdout and stderr, not "all" file descriptors. (It's also considered obsolescent and not suggested for use, even in bash).

              – Charles Duffy
              Jun 7 at 18:58












            • @CharlesDuffy Thank's for correction. I've just fixed it in the own answer!

              – Yurij Goncharuk
              Jun 7 at 20:31













            7












            7








            7







            dash positioned as POSIX standard. POSIX specified only [n]> redirection. But bash introduces many own features. &> is one of them and means output descriptors (stderr and stdout).



            You should read article about bash and dash compatibility.



            Maybe you get helpful checkbashisms utility which can helps to find bash-specific instructions in your scripts.






            share|improve this answer















            dash positioned as POSIX standard. POSIX specified only [n]> redirection. But bash introduces many own features. &> is one of them and means output descriptors (stderr and stdout).



            You should read article about bash and dash compatibility.



            Maybe you get helpful checkbashisms utility which can helps to find bash-specific instructions in your scripts.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jun 7 at 20:31

























            answered Jun 6 at 22:48









            Yurij GoncharukYurij Goncharuk

            3,0902928




            3,0902928







            • 1





              &> is only stdout and stderr, not "all" file descriptors. (It's also considered obsolescent and not suggested for use, even in bash).

              – Charles Duffy
              Jun 7 at 18:58












            • @CharlesDuffy Thank's for correction. I've just fixed it in the own answer!

              – Yurij Goncharuk
              Jun 7 at 20:31












            • 1





              &> is only stdout and stderr, not "all" file descriptors. (It's also considered obsolescent and not suggested for use, even in bash).

              – Charles Duffy
              Jun 7 at 18:58












            • @CharlesDuffy Thank's for correction. I've just fixed it in the own answer!

              – Yurij Goncharuk
              Jun 7 at 20:31







            1




            1





            &> is only stdout and stderr, not "all" file descriptors. (It's also considered obsolescent and not suggested for use, even in bash).

            – Charles Duffy
            Jun 7 at 18:58






            &> is only stdout and stderr, not "all" file descriptors. (It's also considered obsolescent and not suggested for use, even in bash).

            – Charles Duffy
            Jun 7 at 18:58














            @CharlesDuffy Thank's for correction. I've just fixed it in the own answer!

            – Yurij Goncharuk
            Jun 7 at 20:31





            @CharlesDuffy Thank's for correction. I've just fixed it in the own answer!

            – Yurij Goncharuk
            Jun 7 at 20:31










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









            draft saved

            draft discarded


















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












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











            droso 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%2f523421%2fwhy-does-cat-1-dev-stdin-dev-null-work-in-bash-but-not-dash%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

            Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

            Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

            Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?