The default output of the stat command in FreeBSD was completely different from what I got used to in Linux. For example:
linux% stat /boot/vmlinuz-linux File: ‘/boot/vmlinuz-linux’ Size: 3269840 Blocks: 6416 IO Block: 1024 regular file Device: 801h/2049d Inode: 12 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2012-08-28 23:35:55.000000000 +0300 Modify: 2012-08-26 11:19:01.000000000 +0300 Change: 2012-08-28 23:35:47.000000000 +0300 Birth: -
vs
freebsd% /usr/bin/stat /boot/boot0 1149243074 13 -r--r--r-- 1 root wheel 0 512 "Jul 12 18:52:22 2012" "Mar 2 10:39:17 2011" "Feb 11 16:24:47 2012" "Feb 11 16:24:47 2012" 4096 2 0 /boot/boot0
Found it hard to read, I made some use of the -f argument to get it uniformed. Here’s the alias I use and the new output:
freebsd% alias stat="/usr/bin/stat -f \" File: '%N'%SY%n Size: %-15z Blocks: %-10b IO Block: %-6k %HT%nDevice: %7Hr/%-7Lr Inode: %-11i Links: %l%nAccess: (%Mp%Lp/%Sp) Uid: (%5u/%8Su) Gid: (%5g/%8Sg)%nAccess: %Sa%nModify: %Sm%nChange: %Sc%n Birth: %SB\" -t '%F %T %z'" freebsd% stat /boot/boot0 File: '/boot/boot0' Size: 512 Blocks: 2 IO Block: 4096 Regular File Device: 0/0 Inode: 13 Links: 1 Access: (0444/-r--r--r--) Uid: ( 0/ root) Gid: ( 0/ wheel) Access: 2012-07-12 18:52:22 +0000 Modify: 2011-03-02 10:39:17 +0000 Change: 2012-02-11 16:24:47 +0000 Birth: 2012-02-11 16:24:47 +0000
Looks much better huh?
Reblogged this on Gigable – Tech Blog.
You worked too hard at that. Try stat -x to get the verbose output like Linux.
This post predates FreeBSD 10 where -x was introduced. See https://www.freebsd.org/cgi/man.cgi?query=stat&apropos=0&sektion=1&manpath=FreeBSD+Ports+9.2-RELEASE&arch=default&format=html
Anyhow, people using newer version might be interested in your solution. I’m not a FreeBSD guy anymore.
Thank you, this is the best answer I was looking for :)