Skip to main content

Tedshd's Dev note

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

Table of Contents

# 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命令的结果作为下一个命令的参数