When I type sudo du -sh ~student1 I get the output I expect (see screenshot). However when I try to use the script below:
#!/bin/bash
for user in "$@"; do
sudo du -sh ~$user
done
to do the same thing, I get an error that the directory doesn't exist. Here is a screenshot.
(I know I can do sudo du -sh student1 student2..., and that the bash script is useless but I still don't understand why it doesn't work.)
I had a look at Total disk usage for a particular user but it wasn't quite what I was looking for.