Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to display files with permission number in mac terminal?

Tags:

macos

ls

I have tried:

stat -c '%a %n' *

this does display what I want, but this runs in amazon ec2.

Im running on my mac, when I tried to run:

sh-3.2# stat -c '%a %n' *
stat: illegal option -- c
usage: stat [-FlLnqrsx] [-f format] [-t timefmt] [file ...]
sh-3.2# 

The format that I would like to see is:

755 app
644 artisan
755 bootstrap
644 composer.json
644 composer.lock
755 config
755 credentials
755 database
644 package.json
644 package-lock.json
644 phpunit.xml
755 public
755 resources
755 routes
644 server.php
777 storage
755 tests
755 vendor
644 webpack.mix.js
777 worker.log
644 yarn.lock

This displays if I used this command stat -c '%a %n' * in AWS ec2 linux instance.

like image 680
KD.S.T. Avatar asked Sep 15 '25 03:09

KD.S.T.


1 Answers

Hopefully this will work for you:

stat -f "%p %N" * | awk '{$1=substr($1,length($1)-2)}1'
755 Benchmark
755 BoundedBuffer
755 CImgGenerateVideo
755 CImgInterpolate
755 Flask
755 Folder
644 LUT.png
755 Mosquitto
644 MrBean.jpg
755 ThreadSync
644 URLs.txt
like image 150
Mark Setchell Avatar answered Sep 17 '25 20:09

Mark Setchell