I'm trying to write a script that lists the absolute paths of all of a given user's home files and directories, recursively, and writes all of them to an array. Currently, I'm using find like so ...
user="foobar"
usersHomeFiles=( $(find ~$user -printf "%p\\n") )
However, when I execute this script it tells me ...
find: `~foobar': No such file or directory
Even though foobar
is a valid user with a home directory. I even get the same error running it with user="root"
. Any ideas how I could fix this so the find command works in my script?