Vis fil rettigheder i cifre

Skrevet af: Patrick Kerwood

Nogle gange kan det være rart at få vist fil rettighederne i en mappe, i cifre. Heldigvis kan stat vise præcis det og meget mere.

Normalt når man kører en ls -l, lister man filer som nedenstående, hvor rettighederne bliver vist som drwxr-xr-x.

Brug denne kommando for at liste filerne med deres rettigheder i cifre.
stat -c "%a %A %n" *

Kommandoen kan være lidt lang håret at huske, så for at gøre det nemmere, kan du lave et alias. Se her hvordan.

Stat har flere argumenter, hvis du ønsker et anderledes output.

The valid format sequences for files (without --file-system):

%a - Access rights in octal
%A - Access rights in human readable form
%b - Number of blocks allocated (see %B)
%B - The size in bytes of each block reported by %b
%C - SELinux security context string
%d - Device number in decimal
%D - Device number in hex
%f - Raw mode in hex
%F - File type
%g - Group ID of owner
%G - Group name of owner
%h - Number of hard links
%i - Inode number
%n - File name
%N - Quoted file name with dereference if symbolic link
%o - I/O block size
%s - Total size, in bytes
%t - Major device type in hex
%T - Minor device type in hex
%u - User ID of owner
%U - User name of owner
%x - Time of last access
%X - Time of last access as seconds since Epoch
%y - Time of last modification
%Y - Time of last modification as seconds since Epoch
%z - Time of last change
%Z - Time of last change as seconds since Epoch

27 feb 2014   | Alle · Bash

Leave a Reply