tedshd's DevNote

Develop & Design Note by Ted

Mac - Get file user(owner) name & user id

Mac - Get file user name & user id

Get file owner name

stat -f '%Su' <file or folder name>

Get user id

show user
id
// or
id <user name>
get uid
id -u
// or
id -u <user name>

get file owner uid

stat -f '%Su' <file or folder name> | xargs id -u

stat -f '%u' <file or folder name>

Refer - 将Linux命令的结果作为下一个命令的参数

comments powered by Disqus