I think:
Code:
MOD='ipv6'
lsmod | grep [^^]$MOD | less -S
will give the answer you are looking for. You can omit the "
less" at the risk of being confused by folded output lines. You could also/instead pipe it into a column selector that would remove the "(Used) by" modules. E.g., an
awk or
cut statement.
Notes on lsmod
The man page is, to say the least, sparse. IMNRHO, its brevity sucks. (With all due respect to the author, Rusty Russell, who is legendary for his work on netfilter & iptables.)
It is so bad, I originally thought there is a bug in the headers: column 3 seemed to be the # pages the module uses & col. 4 the list of other modules that use it.
http://www.faqs.org/faqs/linux/faq/part4/ seems to support this idea:
Code:
Module Pages Used by
memory_cs 2 0
ds 2 [memory_cs] 3
i82365 4 2
However,
http://www.cyberciti.biz/faq/howto-d...kernel/print/:
Quote:
|
First column is Module name and second column is size of modules i..e the output format is module name, size, use count, list of referring modules.
|
and
http://osdir.com/ml/linux.evms.devel...msg00045.html:
Quote:
At a given time, if a module has "0" in the lsmod "Used" column and either
nothing or (unused) or (autoclean) in the "by" column, there are reasonable
chances that it is unused.
|
say otherwise.
An explanation of the meaning of the columns in the man page would save countless hours of grief. Changing "by" to "...by" in the headers wouldn't hurt either.
Why not change
Quote:
|
lsmod is a trivial program which nicely formats the contents of the /proc/modules, showing what kernel modules are currently loaded.
|
to
Quote:
lsmod is a trivial program which nicely formats the contents of /proc/modules, showing what kernel modules are currently loaded in a 4 column format: "Module" - the name of the module
"Size" - the amount of memory it uses
"Used" - its use count
"by" - a "tight" (no spaces) comma separated list of referring modules Although it only appears once - for brevity in the output - "Used" is to be mentally read twice: i.e. "by" is to be understood as "Used by", that is why it is not capitalized.
|
I also don't like
lsmod's column formatting, esp. col. #3.
Code:
lsmod | awk '{printf "%-21s %6s %2s %s\n",$1,$2,$3,$4}'
or
Code:
lsmod \
| sed '1s,by,...by,' \
| awk '{printf "%-21s %6s %2s %s\n",$1,$2,$3,$4}'
would be a good aliases for the current
lsmod.