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

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

I think I could just do:

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

but this seems like a simpler answer to the problem.

+6
source share
2 answers

Try using stat(1)

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

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

+13
source

You can also use the find :

 find -maxdepth 1 -name 'file.c' -printf '%u\n' 
+2
source

Source: https://habr.com/ru/post/906330/


All Articles