user3151788 user3151788 - 5 days ago 6
Linux Question

How to get a bare, recursive directory listing in Linux, excluding some directories

I need to obtain a recursive directory listing in Linux with only the directory and file name. It needs to include all files including hidden files with the exception of files name “.svn”.

I have tried multiple combinations of the “ls” command and haven’t been able to figure it out. When using “ls –R direname/ grep –v /$” I get a directory heading followed by a colon, which I cannot use.

If I have a directory name test with files and a sub-directory named test2 with files, I need the output to look like the following:


test
test/.filehidden1
test/file2
test/file3.txt
test/test2.log
test/test2/file.hidden1
test/test2/file2.boo
test/test2/file3.boo2


Notice there is no leading forward slash

Answer
find . -name .svn -prune -o -print

-prune tells it to not descend into any matching directories.

Comments