2

The command I'm running is: ls -alFs --block-size=1

The following is the output:

4096 -rw-rw-r-- 1 dkm dkm 320 Oct 5 15:28 QRN_1570310934.charbin
4096 -rw-rw-r-- 1 dkm dkm 320 Oct 5 15:29 QRN_1570310939.charbin
4096 -rw-rw-r-- 1 dkm dkm 320 Oct 5 15:29 QRN_1570310946.charbin
8192 -rw-rw-r-- 1 dkm dkm 8192 Oct 8 11:33 QRN_1570555988.charbin
8192 -rw-rw-r-- 1 dkm dkm 8190 Oct 8 11:35 QRN_1570556100.charbin
4096 -rw-rw-r-- 1 dkm dkm 340 Oct 8 11:35 QRN_1570556140.charbin

on the far left is the size output from the -s switch showing in bytes due to --block-size=1, but the -l switch's output sizes (6th column from the left) are radically different for quite a few files. I've been trying to figure this out and I haven't been able to get a definite answer anywhere.

My best guess is that the -s switch is giving me device blocks and the -l switch is giving me the actual byte size. That's what it looks like but how do I know for certain? The 'ls' man page isn't giving me any details as to how the size output for the -l switch is derived.

Any suggestions for other tools I can use to try to figure this out ... or better yet; if anybody actually knows, that would be even better.

Thank you in advance.

3
  • 1
    Type echo 12345 > /tmp/test then ls -l /tmp/test and you will it is 5 bytes as expected. Commented Oct 16, 2019 at 17:30
  • @WinEunuuchs2Unix The resulting file size will be 6 bytes. There's a trailing newline character.
    – doneal24
    Commented Oct 16, 2019 at 17:59
  • Thanks I was typing from phone and not computer to verify test. Commented Oct 16, 2019 at 19:36

1 Answer 1

2

The -s or --size option prints the disk allocation of each file while with the l option the size is printed as a byte count.

Source: https://www.gnu.org/software/coreutils/manual/html_node/What-information-is-listed.html#What-information-is-listed

3
  • exactly what I was trying to figure out. Thank you. I suspected it was something like that but I couldn't find any documentation. So, thank you for the link. Much appreciated :) Commented Oct 16, 2019 at 17:40
  • You'll find a link to the full documentation in man ls at the very end.
    – mook765
    Commented Oct 16, 2019 at 17:42
  • oh - weird. That was the first place I looked. I must have somehow missed it. shrugs oh well. Thank you. Commented Oct 16, 2019 at 17:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .