Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • dirname /tmp/foo/bar will give /tmp or dirname foo/bar/baz will give foo Commented Nov 9, 2011 at 15:42
  • 1
    @greenmang0: Flagged your answer. First, it's plain wrong (did you even execute those commands?), and second it's for a makefile, not Bash. Commented Nov 9, 2011 at 16:18
  • @l0b0 It's a comment, and "it's wrong" isn't a good reason to flag anything, just leave a comment saying what the problem is Commented Nov 9, 2011 at 16:23
  • @MichaelMrozek: I flagged it "not constructive / off topic", both of which applies to it. Commented Nov 9, 2011 at 19:51
  • I don't understand your question: what do you mean by “the top-level directory part”? Do you mean the part before the first /? Do you guarantee that the argument is a relative path? Are you assuming GNU make? Commented Nov 9, 2011 at 23:05