Search code examples
ls

Tell "ls -laR /": do not recurse into other filesystems


I occasionally do "ls -laR /" on my system and offsite backup the results. If disaster strikes, I'll at least know which files I've lost.

I recently started sshfs mounting remote systems, yielding two problems:

  • "ls -laR" on sshfs mounted systems is painfully slow

  • I don't need the "ls -laR" results of remote filesystems, at least not locally.

What's the ls equivalent of find's "-xdev" option or du's "-x" option?

In case there's a better way to do it, my goal is to efficiently get a list of all files on my hard drive with size, owner, mod time, etc. In other words, all the info "ls -l" would normally provide.

I've considered: "find / -xdev | xargs ls -la", but I sense that would be less efficient.


Solution

  • There is no such option for ls itself, but you can do

    find / -xdev -ls
    

    or if that is not sufficiently detailed, look into the possibilities offered by the -printf option.