I'm using linux to analyze a windows directory structure. The structure is:
/Documents and settings
/username1
/My Documents
...
/username2
/My Documents
...
...
What command can I execute so that the contents (and sub folders) of all the "My Documents" directories are listed like:
/Documents and Settings/username1/My Documents/filename
/Documents and Settings/username1/My Documents/subdir/filename
/Documents and Settings/username2/My Documents/filename
Basically there are a ton of users but almost none have anything in their My Documents folder. I just want to find and show the contents of those user's that do have documents.
EDIT: Each "username" directory contains many sub directories. I only want to list the tree below the My Documents folder but do so for all usernames at once.
Best Answer
Combining the first two answers, use find and ls -R:
find "/Documents and settings" -name "My Documents" -exec ls -R {} \;
This will find all of the My Documents directories and list everything underneath them, with full pathnames. You need the quotes since the directory names have spaces in them.
Edit: An explination of how this works. It starts at /Documents and settings, looking for any file or directory that matches My Documents. For each one it finds, it substitutes the path for {} in the ls. The \; signifies the end of the command.