The question What is the Linux equivalent of DOS “dir /s /b filename”? comes close but it winds up playing a file find operation for all such named file names.

I'm however looking to do a directory contents diff comparison with a directory on a Windows machine and compare it to what should be a similarly constructed directory on a QNX box. I want to run the directory enumerating command on both machines, do some text file manipulation to convert path delimiting characters and root drives and what not to get them into a compatible format for an insightful diff.

I can generate a folder manifest of all subdirectories and files therein with dir /b /s, and get output formatted as a bunch of paths...

c:\Temp>dir /b /s

I can see dir /s becomes ls -R, but how do I get the /B equivalent of the path output formatting?

  • 6
    The answer is the same as in the other question, except you leave out the -name option, so it doesn't filter by name.
    – Barmar
    Commented Feb 17, 2017 at 18:55

4 Answers 4


There isn't a flag for ls which will do what you ask, but you can accomplish it with several other tools, the easiest being (possibly) find:

find .
  • 2
    or simply find The default expression is . Commented Feb 17, 2017 at 18:58
  • 3
    True. Anyway I think it is a good practice to include defaults in Q/A posts, as they might not be obvious to everyone.
    – Bruno9779
    Commented Feb 17, 2017 at 19:00
  • 19
    @user4556274 It may be for GNU find, but other implementations follow the POSIX standard and requires a directory operand.
    – Kusalananda
    Commented Feb 17, 2017 at 19:21

find may give you all that you need. It has a little more overhead as it performs more tests than ls alone, but if you want the path information in the output then this may be the simplest way to achieve that.

If you're going to compare two systems, then you should probably do some text editing first and swap \ with /, and remove the C: prefix. Then sort the lists and use diff to spot the changes. sed will be your friend here. Follow-up with a comment if you want this too.


tree -if

-i to not indent -f to print path

  • Interesting, show some console output to your answer; I can't find that command from my QNX box -bash: tree: command not found
    – jxramos
    Commented Feb 17, 2017 at 23:12
  • I'm on my phone so can't test it, but it's in the man page at linux.die.net/man/1/tree
    – Stephen C
    Commented Feb 17, 2017 at 23:27
  • 1
    It's from mama.indstate.edu/users/ice/tree, and packaged as tree in a number of Linux distributions.
    – deltab
    Commented Feb 18, 2017 at 1:09
  • tree is my tool of choice to inspect directory structure, but it is not installed by default on most systems.
    – Bruno9779
    Commented Feb 20, 2017 at 12:47

In order to get the actual path prefixed (assuming that's important), do

find "$(pwd)"
  • If you are using a bash-like shell, no need to invoke an external command; find "${PWD}" should be enough. Not sure if that works on QNX, though.
    – user
    Commented Feb 18, 2017 at 14:02
  • @MichaelKjörling: Well if you want the symlink path rather than the real path ...
    – Joshua
    Commented Feb 18, 2017 at 21:29
  • True, it might depend on the exact semantics of each. Don't forget that at least GNU bash has a built-in pwd as well as the external /bin/pwd, too, which also differ in how they handle directories reached by symlinks.
    – user
    Commented Feb 19, 2017 at 11:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .