dirname appears not to work with xargsman xargs says standard input is delimited by blanks; but is it?using...

Is there any differences between “gucken” and “schauen”?

Is residual finiteness a quasi isometry invariant for f.g. groups?

How does 子 come to mean 'midnight'?

What is this metal M-shaped device for?

Overfitting and Underfitting

Would a National Army of mercenaries be a feasible idea?

Citing paywalled articles accessed via illegal web sharing

Placing an adverb between a verb and an object?

Using only 1s, make 29 with the minimum number of digits

Chess tournament winning streaks

It took me a lot of time to make this, pls like. (YouTube Comments #1)

Notes in a lick that don't fit in the scale associated with the chord

Why is working on the same position for more than 15 years not a red flag?

Can I write a book of my D&D game?

Word or phrase for showing great skill at something without formal training in it

Could flying insects re-enter the Earth's atmosphere from space without burning up?

Why do members of Congress in committee hearings ask witnesses the same question multiple times?

How to acknowledge an embarrassing job interview, now that I work directly with the interviewer?

Is a debit card dangerous for an account with low balance and no overdraft protection?

Avoiding morning and evening handshakes

Do authors have to be politically correct in article-writing?

Program that converts a number to a letter of the alphabet

Checking for the existence of multiple directories

What does Cypher mean when he says Neo is "gonna pop"?



dirname appears not to work with xargs


man xargs says standard input is delimited by blanks; but is it?using xargs to grep multiple patternsLinux: Does find | xargs grep have limitations?Understanding -regex with GNU findechoing basename under xargs?Find files recursively that are older than one year and not owned by a specific userHow to use `yes` with `xargs -p`?Chaining grep commandsHow do I get xargs to show me the command lines it's generating without running them?xargs interface for tar balls













1















xargs and basename work together as I would expect:



$ printf '%sn' foo/index.js bar/index.js baz/index.js | xargs basename
index.js
index.js
index.js


xargs and dirname, though, appear not to work together:



$ printf '%sn' foo/index.js bar/index.js baz/index.js | xargs dirname
usage: dirname path


I would expect



foo
bar
baz


as output. What am I missing?



I'm on Darwin 18.2.0 (macOS 10.14.3).










share|improve this question









New contributor




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

























    1















    xargs and basename work together as I would expect:



    $ printf '%sn' foo/index.js bar/index.js baz/index.js | xargs basename
    index.js
    index.js
    index.js


    xargs and dirname, though, appear not to work together:



    $ printf '%sn' foo/index.js bar/index.js baz/index.js | xargs dirname
    usage: dirname path


    I would expect



    foo
    bar
    baz


    as output. What am I missing?



    I'm on Darwin 18.2.0 (macOS 10.14.3).










    share|improve this question









    New contributor




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























      1












      1








      1








      xargs and basename work together as I would expect:



      $ printf '%sn' foo/index.js bar/index.js baz/index.js | xargs basename
      index.js
      index.js
      index.js


      xargs and dirname, though, appear not to work together:



      $ printf '%sn' foo/index.js bar/index.js baz/index.js | xargs dirname
      usage: dirname path


      I would expect



      foo
      bar
      baz


      as output. What am I missing?



      I'm on Darwin 18.2.0 (macOS 10.14.3).










      share|improve this question









      New contributor




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












      xargs and basename work together as I would expect:



      $ printf '%sn' foo/index.js bar/index.js baz/index.js | xargs basename
      index.js
      index.js
      index.js


      xargs and dirname, though, appear not to work together:



      $ printf '%sn' foo/index.js bar/index.js baz/index.js | xargs dirname
      usage: dirname path


      I would expect



      foo
      bar
      baz


      as output. What am I missing?



      I'm on Darwin 18.2.0 (macOS 10.14.3).







      osx xargs dirname






      share|improve this question









      New contributor




      davidchambers 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




      davidchambers 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 1 hour ago









      Jeff Schaller

      42.8k1159136




      42.8k1159136






      New contributor




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









      asked 3 hours ago









      davidchambersdavidchambers

      1084




      1084




      New contributor




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





      New contributor





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






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






















          2 Answers
          2






          active

          oldest

          votes


















          3














          dirname on macOS only takes a single pathname, whereas basename is able to work with multiple pathnames. It is however safest to call basename with a single pathname so that it does not accidentally try to remove the the second pathname from the end of the first, as in



          $ basename some/file e
          fil


          When calling these utilities from xargs you may ask xargs to run the utility with a single newline-delimited string at a time:



          printf '%sn' some arguments | xargs -I {} basename {}


          or,



          printf '%sn' some arguments | xargs -I {} dirname {}


          You could also use xargs -L 1 utility rather than xargs -I {} utility {}.






          share|improve this answer



















          • 1





            I fundamentally misunderstood xargs. I was under the impression that its default behaviour was to execute the utility once for each input line. Thanks for correcting my understanding.

            – davidchambers
            15 mins ago



















          1














          dirname only takes 1 argument; while the GNU/coreutils version of dirname can take more than 1 argument, that is a non-standard extension:



          SYNOPSIS

          dirname string





          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "106"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            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
            });


            }
            });






            davidchambers 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%2f503944%2fdirname-appears-not-to-work-with-xargs%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3














            dirname on macOS only takes a single pathname, whereas basename is able to work with multiple pathnames. It is however safest to call basename with a single pathname so that it does not accidentally try to remove the the second pathname from the end of the first, as in



            $ basename some/file e
            fil


            When calling these utilities from xargs you may ask xargs to run the utility with a single newline-delimited string at a time:



            printf '%sn' some arguments | xargs -I {} basename {}


            or,



            printf '%sn' some arguments | xargs -I {} dirname {}


            You could also use xargs -L 1 utility rather than xargs -I {} utility {}.






            share|improve this answer



















            • 1





              I fundamentally misunderstood xargs. I was under the impression that its default behaviour was to execute the utility once for each input line. Thanks for correcting my understanding.

              – davidchambers
              15 mins ago
















            3














            dirname on macOS only takes a single pathname, whereas basename is able to work with multiple pathnames. It is however safest to call basename with a single pathname so that it does not accidentally try to remove the the second pathname from the end of the first, as in



            $ basename some/file e
            fil


            When calling these utilities from xargs you may ask xargs to run the utility with a single newline-delimited string at a time:



            printf '%sn' some arguments | xargs -I {} basename {}


            or,



            printf '%sn' some arguments | xargs -I {} dirname {}


            You could also use xargs -L 1 utility rather than xargs -I {} utility {}.






            share|improve this answer



















            • 1





              I fundamentally misunderstood xargs. I was under the impression that its default behaviour was to execute the utility once for each input line. Thanks for correcting my understanding.

              – davidchambers
              15 mins ago














            3












            3








            3







            dirname on macOS only takes a single pathname, whereas basename is able to work with multiple pathnames. It is however safest to call basename with a single pathname so that it does not accidentally try to remove the the second pathname from the end of the first, as in



            $ basename some/file e
            fil


            When calling these utilities from xargs you may ask xargs to run the utility with a single newline-delimited string at a time:



            printf '%sn' some arguments | xargs -I {} basename {}


            or,



            printf '%sn' some arguments | xargs -I {} dirname {}


            You could also use xargs -L 1 utility rather than xargs -I {} utility {}.






            share|improve this answer













            dirname on macOS only takes a single pathname, whereas basename is able to work with multiple pathnames. It is however safest to call basename with a single pathname so that it does not accidentally try to remove the the second pathname from the end of the first, as in



            $ basename some/file e
            fil


            When calling these utilities from xargs you may ask xargs to run the utility with a single newline-delimited string at a time:



            printf '%sn' some arguments | xargs -I {} basename {}


            or,



            printf '%sn' some arguments | xargs -I {} dirname {}


            You could also use xargs -L 1 utility rather than xargs -I {} utility {}.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 3 hours ago









            KusalanandaKusalananda

            133k17254417




            133k17254417








            • 1





              I fundamentally misunderstood xargs. I was under the impression that its default behaviour was to execute the utility once for each input line. Thanks for correcting my understanding.

              – davidchambers
              15 mins ago














            • 1





              I fundamentally misunderstood xargs. I was under the impression that its default behaviour was to execute the utility once for each input line. Thanks for correcting my understanding.

              – davidchambers
              15 mins ago








            1




            1





            I fundamentally misunderstood xargs. I was under the impression that its default behaviour was to execute the utility once for each input line. Thanks for correcting my understanding.

            – davidchambers
            15 mins ago





            I fundamentally misunderstood xargs. I was under the impression that its default behaviour was to execute the utility once for each input line. Thanks for correcting my understanding.

            – davidchambers
            15 mins ago













            1














            dirname only takes 1 argument; while the GNU/coreutils version of dirname can take more than 1 argument, that is a non-standard extension:



            SYNOPSIS

            dirname string





            share|improve this answer




























              1














              dirname only takes 1 argument; while the GNU/coreutils version of dirname can take more than 1 argument, that is a non-standard extension:



              SYNOPSIS

              dirname string





              share|improve this answer


























                1












                1








                1







                dirname only takes 1 argument; while the GNU/coreutils version of dirname can take more than 1 argument, that is a non-standard extension:



                SYNOPSIS

                dirname string





                share|improve this answer













                dirname only takes 1 argument; while the GNU/coreutils version of dirname can take more than 1 argument, that is a non-standard extension:



                SYNOPSIS

                dirname string






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 3 hours ago









                Uncle BillyUncle Billy

                6016




                6016






















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










                    draft saved

                    draft discarded


















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













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












                    davidchambers 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%2f503944%2fdirname-appears-not-to-work-with-xargs%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

                    Fairchild Swearingen Metro Inhaltsverzeichnis Geschichte | Innenausstattung | Nutzung | Zwischenfälle...

                    Pilgersdorf Inhaltsverzeichnis Geografie | Geschichte | Bevölkerungsentwicklung | Politik | Kultur...

                    Marineschifffahrtleitung Inhaltsverzeichnis Geschichte | Heutige Organisation der NATO | Nationale und...