How to view a files owner if username is + 8 chars?
I'm a little embarrassed to be asking such a newb question like this,
but how would I view a files owner if username is + 8 chars? Is there a simple ls option (I couldnt find it) to do this? Or perhaps another command I am forgetting about? Other then greping the passwd file, how would one find this information out?
Signature · 2 lines
Thanks,
Brandon E.Quoted 5 lines · Brandon Evans
I'm a little embarrassed to be asking such a newb question like this,
but how would I view a files owner if username is + 8 chars? Is there a simple ls option (I couldnt find it) to do this? Or perhaps another command I am forgetting about? Other then greping the passwd file, how would one find this information out?
The "stat" utility can handle usernames longer than 8 characters. So can the '%u' directive for "find ... -printf ...".
You can get roughly the same behaviour as "ls -l" with:
find $dir -mindepth 1 -maxdepth 1 -printf '%04m %3n %8u %8g %9s %Tb %Td %TY %f %l\n'
except that the above will expand fields to the specified width but won't truncate them if they are longer.
Unfortunately, you can't get the permissions in rwxr-xr-x format, you can't get it display the type (file, directory etc), and you can't get the variable date/time format (i.e. display the time for recent files, display the year for older ones).
BTW, "find" also has an "-ls" option, which is similar to "ls -ls", but that also truncates the user/group to 8 characters.
Signature · 1 line
Glynn Clements <[email protected]>
Quoted 11 lines · Glynn Clements
Brandon Evans wrote:
The "stat" utility can handle usernames longer than 8 characters. So can the '%u' directive for "find ... -printf ...".
You can get roughly the same behaviour as "ls -l" with:
find $dir -mindepth 1 -maxdepth 1 -printf '%04m %3n %8u %8g %9s %Tb %Td %TY %f %l\n'
nice. stat will work just fine. Thank you!
Signature · 2 lines
Thanks,
Brandon E.