Reputation:
Help to write script. How to Using Loop, print Filename and its Owner in current directory
Example:
filename: file1, owner: sysadm
filename: file2, Owner: sysadm```
Upvotes: 0
Views: 146
Reputation: 212604
There's no need for a loop, but implementations of stat
differ. On Linux, you can probably just do:
stat -c 'Filename: %-40N owner: %U' *
On Macos, you may want to use:
stat -f 'Filename: %-40N owner: %Su' *
Upvotes: 5
Reputation: 13189
awk implicitly loops over its input
ls -al |awk '/^-/ {print "Filename:",$9 ", Owner:",$3}'
Upvotes: 0