Since, you want to decipher from the output that you have got, we will try and simplify things.
ls -ld
drwxr-xr-x 4 root root 4096 Nov 11 14:29 .
Now, ls -ld
on a directory gives me the output as above. Now, the number 4 is something that you need to concentrate on. The 4 corresponds to:
- the entry for that directory in its parent directory;
- the directory's own entry for
.
;
- the
..
entries in the 2 sub-directories inside the directory.
To verify this, if I just issue ls
I could see that I have couple of more directories. So, this gives an idea of what we could decipher from the output of your case.
drwxr-xr-x 2014 K-rock users 65536 20011-11-05 11:34
There are 2012 sub-directories inside which is why you get 2014 in the output.
As to the number of files, it is not possible to find it out from the output that you have.
To test if my theory is correct, I did the below testing.
ls -la | grep -E '[d]' #Display only directories
drwxr-xr-x 12 root root 4096 Nov 11 14:42 .
drwxr-xr-x 4 root root 4096 Nov 11 14:20 ..
drwxr-xr-x 3 root root 4096 Nov 11 14:45 hello1
drwxr-xr-x 2 root root 4096 Nov 11 14:42 hello2
drwxr-xr-x 2 root root 4096 Nov 11 14:42 hello3
drwxr-xr-x 2 root root 4096 Nov 11 14:42 hello4
drwxr-xr-x 2 root root 4096 Nov 11 14:42 hello5
drwxr-xr-x 2 root root 4096 Nov 11 14:42 hello6
drwxr-xr-x 2 root root 4096 Nov 11 14:42 hello7
drwxr-xr-x 2 root root 4096 Nov 11 14:42 hello8
drwxr-xr-x 2 root root 4096 Nov 11 14:21 hello-subdir
drwxr-xr-x 2 root root 4096 Nov 11 14:29 spaced hello
Now, I issue ls -ld
command and the output I get is,
ls -ld
drwxr-xr-x 12 root root 4096 Nov 11 14:42 .
It did not take into consideration the files or subdirectories nested inside the subdirectories of the folder. Basically, the above command says I have 10 directories inside my folder.
P.S.: It is often a bad idea to parse something from ls
output as it is not reliable. Use find
with -maxdepth
instead if you have a chance to use it.
With zsh
, using an associative array whose keys are the dates and values the NUL-delimited list of files last modified on that date:
zmodload -F zsh/stat b:zstat
typeset -A files
for file (./*) {
zstat -LA date -F %b_%d +mtime $file &&
files[$date]+=$file$'\0'
}
for date (${(k)files})
echo tar zcvf $date.tar.gz ${(0)files[$date]}
Remove the echo
when happy.
Note that the month name abbreviations (%b
strftime format) will be in the current locale's language (Oct
on an English system, Okt
on a German one, etc.). To always make it English names regardless of the user's locale, force the locale to C
with LC_ALL=C zstat...
.
With GNU tools, you could do the equivalent with:
find . ! -name . -prune ! -name '.*' -printf '%Tb_%Td:%p\0' |
awk -v RS='\0' -F : -v q=\' '
function quote(s) {
gsub(q, q "\\" q q, s)
return q s q
}
{
date=$1
sub(/[^:]*:/, "", $0)
files[date] = files[date] " " quote($0)
}
END {
for (date in files)
print "tar zcvf " quote(date ".tar.gz") files[date]
}'
Pipe to sh
when happy.
Best Answer
Those files are special files called devices.
They don't have a size parameter, but two number called major and minor number.
Major is somehow related to type of device (terminal, disks, network interface, filesystems).
Minor is related instance number.
I use the word "related", you simply do not count, different disk might have different major number. Computing of this two value is complex, and is mostly done by your OS.
insf -e
to create those devicedevfsadm -c disk
for diskcfgadm -a
(from memory)EDIT:
b) you seldom have a use for those number, as I mention misceleanous utilities manage them for you. a) you mostly cannot manualy compute those number. You know them or not. I use them only once, in HP-UX 11Iv1, volume group creation involve using
mknod /dev/vgX c 64 0x010000
, 64 being major and 0X010000 being minor. It was user responsabilities to manage minor number.