Can someone explain to me the following?$ ls -ld /temp/sit/build/dr-xr-s--- 3 asdf qwer 4096 Jan 31  2012 /temp/sit/build/$ ls -ld /temp/sit/build/*ls: /temp/sit/build/*: Permission deniedSo apprently, I can't use the asterisk here. I've tried it with a sudo command and I get a no such file error rather than permission denied...sudo ls -l /temp/sit/build/*ls: /temp/sit/build/batch*: No such file or directorybut it finally works if I don't use the *sudo ls -l /temp/sit/build/total 4dr-xr-s--- 11 asdf qwer 4096 Oct  3 23:31 file
Cannot expand asterisk without proper permission
shell;permissions;sudo;wildcards
The shell that's doing the expansion of the * wildcard is the shell where you type it. If the shell has the permission to read the list of files in the directory, then it expands /temp/sit/build/* to /temp/sit/build/file, and runs sudo with the arguments ls, -l and /temp/sit/build/file. If the shell is unable to find any match for /temp/sit/build/* (whether it's because there are no matches, or because the shell has no permission to see the matches), then it leaves the pattern alone, and sudo is called with the arguments ls, -l and /temp/sit/build/*.Since there is no file called /temp/sit/build/*, the ls command complains if you pass it that name. Recall that ls doesn't expand wildcards, that's the shell's job.If you want wildcard expansion to happen in a directory where you don't have read permission, then the expansion must happen in a shell that's started by sudo instead of in the shell that calls sudo. sudo doesn't automatically start a shell, you need to do that explicitly.sudo sh -c 'ls -l /temp/sit/build/*'Here, of course, you can do sudo ls -l /temp/sit/build/ instead, but that doesn't generalize to other patterns.