Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a command to return the owner of a file?

Is there a shell command to just print the owner of a file?

I guess I could just do:

ls -l  | awk '{print $3}'

but this feels like there would be a more straightforward answer to the problem.

like image 792
atxdba Avatar asked Jan 18 '12 18:01

atxdba


1 Answers

Try using stat(1)

[cnicutar@fresh ~]$ stat -c %U file.c
cnicutar

There are lots of format sequences available: user ID, total size, etc.

like image 182
cnicutar Avatar answered Nov 13 '22 07:11

cnicutar