Equivalent to `stat` (e.g. on Debain Distributions) for OpenWrt 19.x?

Hi there

I would like to show filesystem permissions as a numer (e.g. 755, and so on) with a command line tool similar to stat:

On Debian-based distributions i can use stat -c "%a %n" /path/filename for example.

What tool do i need on OpenWRT for that? Is something on the "standard" installation, or do i need to install a new packge via opkg install ... ? If yes, what?

Thank you very much for your feedbacks.

With best regards, Jan

This should do it
ls -l | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf("%0o ",k);print}'

opkg update && opkg install coreutils-stat

@tmomas: works! thank you very much!! :slight_smile:

root@OpenWrt:~#  stat -c "%a %n" /etc/init.d/fwrules
755 /etc/init.d/fwrules

With best regards,

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.