I have several shared folders and I need to find if a user has several folders there.e.g:/shared/release//shared/compile//shared/tags//shared/general/I need a bash script that will list those folders and tell me if a user has more than 1 owned folder.Using bash, how can I get a list of these folders and determine if a user owns more than one? 
find user owned folders
linux;bash;centos;scripting
This will shown which users have more than one directory:find /shared -type d -printf '%u\n' | sort | uniq -dcThis requires GNU find to support the -printf action.  Your CentOS will have this.This will list both the users with more than one directory and their directories:find /shared -type d -printf '%u %p\0' | awk '{c[$1]++; a[$1]=a[$1](a[$1]?\n  :)$0} END{for (user in c) if (c[user]>1) print c[user],a[user]}' RS=\0For maximum flexibility, we used NUL-separated output from find.  To work with this, we need GNU awk or recent versions of mawk that supports NUL-separated input.  Since you are using CentOS, this should be fine.How it worksfind /shared -type d -printf '%u %p\0'This tells find to look for directories under /shared and print out their owner, %u, along with the directory name, %p in a NUL-separated list.awk '{c[$1]++; a[$1]=a[$1](a[$1]?\n  :)$0} END{for (user in c) if (c[user]>1) print c[user],a[user]}' RS=\0This counts up the number of directories each user has and prints a report for users with more than one.  In more detail:c[$1]++ increments the count for the user specified in the first input field.a[$1]=a[$1](a[$1]?\n  :)$0} saves the name of each directory found for this user.END{for (user in c) if (c[user]>1) print c[user],a[user]} prints out the report.RS=\0 tells awk to use NUL-separated input.  This makes the process safe even if directory names contain newlines or other difficult characters.