ls
does not have such flag, but stat
command allows showing octal permissions. Consider sample output for a test file,
testdir:$ stat TESTER
File: ‘TESTER’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 801h/2049d Inode: 1197 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ xieerqi) Gid: ( 1000/ xieerqi)
Access: 2015-11-05 17:42:01.914917433 -0700
Modify: 2015-11-05 17:42:01.914917433 -0700
Change: 2015-11-05 18:41:04.463776180 -0700
Birth: -
stat
also has --format
flag , which allows you to "simulate" ls -l
:
testdir:$ stat --format="%a %h %U %G %s %y %n" * | head -n 3
664 1 xieerqi xieerqi 0 2015-11-05 17:42:01.918917452 -0700 Aaaaaaa.bbb - 0000003 tag tag_tag 9tag
664 1 xieerqi xieerqi 0 2015-11-05 17:42:01.922917471 -0700 Aaaaaaa.bbb - 0000004 tag tag_tag 9tag
664 1 xieerqi xieerqi 0 2015-11-05 17:42:01.930917509 -0700 Aaaaaaa.bbb - 0000005 tag tag_tag 9tag
The only limitation here is the time format cannot be altered and color output cannot be added .
You could always alias that command in .bashrc
to some shorter command, e.g. alias lsl2='stat --format="%a %h %U %G %s %y %n" *'
Alternatively, I've put together a small function that uses find
and awk
for nicer formatting
function lsl2
{
find . -maxdepth 1 | sort | xargs -I{} stat --format="%a %h %U %G %s %y %n" {} | awk '{$7=substr($7,1,5);$8 =" ";print}'
}
Sample output
testdir:$ lsl2 | head -n 7
775 3 xieerqi xieerqi 4096 2015-11-05 22:20 .
664 1 xieerqi xieerqi 0 2015-11-05 17:42 ./Aaaaaaa.bbb - 0000003 tag tag_tag 9tag
664 1 xieerqi xieerqi 0 2015-11-05 17:42 ./Aaaaaaa.bbb - 0000004 tag tag_tag 9tag
664 1 xieerqi xieerqi 0 2015-11-05 17:42 ./Aaaaaaa.bbb - 0000005 tag tag_tag 9tag
664 1 xieerqi xieerqi 0 2015-11-05 17:42 ./Aaaaaaa.bbb - 0000006 tag 9tag
664 1 xieerqi xieerqi 0 2015-11-05 17:42 ./Aaaaaaa.bbb - 0000006 tag tag_tag 9tag
664 1 xieerqi xieerqi 0 2015-11-05 17:42 ./Aaaaaaa.bbb - 0000007 tag 9tag
testdir:$ type lsl2
lsl2 is a function