spikemc1968
Posts: 2
Joined: Sun Jan 14, 2018 12:14 am

ls question (I'm so embarassed..)

Sun Jan 14, 2018 12:24 am

Hi, I'm writing a script that uses the output from the "ls -l" command, and I'm seeing a column between the group and size fields that looks very useful, but I have no idea what it is! Can anyone tell me what the "250," field is in the output below? I checked the man page for ls and searched for a couple hours but I can't figure it out...

crw------- 1 root root 250, 0 Jan 12 13:24 vc-mem

Thank you!

User avatar
rpdom
Posts: 12860
Joined: Sun May 06, 2012 5:17 am
Location: Ankh-Morpork

Re: ls question (I'm so embarassed..)

Sun Jan 14, 2018 2:09 am

In that particular instance you are looking at a device file, not a normal file. Device files are identified by a Major and Minor device number. The first number 250 is the major number, the second number 0 is the minor number.

One example of this is your SD card, where on a standard (non-NOOBS) Raspbian install you will see something like the following

Code: Select all

[email protected]:~ $ ls -l /dev/mmcblk*
brw-rw---- 1 root disk 179, 0 Mar 29  2017 /dev/mmcblk0
brw-rw---- 1 root disk 179, 1 Mar 29  2017 /dev/mmcblk0p1
brw-rw---- 1 root disk 179, 2 Mar 29  2017 /dev/mmcblk0p2
In this case, the Major number that identifies the card device is 179. Minor number 0 is the whole raw card. Minor number 1 is the first partition, Minor number 2 is the second partition.

spikemc1968
Posts: 2
Joined: Sun Jan 14, 2018 12:14 am

Re: ls question (I'm so embarassed..)

Sun Jan 14, 2018 2:19 am

Thank you so much! It's all so clear now... I was in the /dev directory. Now I understand why some files had a "size" of zero (I was mistaking the minor device number for the file size).

Thanks again!

Return to “General programming discussion”