parse "lsmod" output to "dot" format and pass it to "display". Without perl!
Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?
You must be signed in to comment.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
lsmod | perl -e 'print "digraph \"lsmod\" {";<>;while(<>){@_=split/\s+/; print "\"$_[0]\" -> \"$_\"\n" for split/,/,$_[3]}print "}"' | display -
display: no decode delegate for this image format `/tmp/magick-XX6QuBzg'.display -list format | grep DOT
DOT DOT r-- Graphviz I've:display -list configure
Path: /usr/lib/ImageMagick-6.6.0/config/configure.xml Name Value ------------------------------------------------------------------------------- CC gcc -std=gnu99 -std=gnu99 CFLAGS -I/usr/include/lqr-1 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -fopenmp -g -O2 -Wall -W -pthread CONFIGURE ./configure '--prefix=/usr' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--with-modules' '--with-gs-font-dir=/usr/share/fonts/type1/gsfonts' '--with-magick-plus-plus' '--with-djvu' '--enable-shared' '--without-dps' '--without-fpx' '--with-perl-options=INSTALLDIRS=vendor' '--x-includes=/usr/include/X11' '--x-libraries=/usr/lib/X11' 'CFLAGS=-g -O2' 'LDFLAGS=' 'CPPFLAGS=' 'CXXFLAGS=-g -O2' COPYRIGHT Copyright (C) 1999-2010 ImageMagick Studio LLC CPPFLAGS -I/usr/include/ImageMagick CXX g++ CXXFLAGS -g -O2 -Wall -W -pthread DEFS -DHAVE_CONFIG_H DELEGATES bzlib djvu fontconfig freetype gvc jpeg jng jp2 lcms lqr openexr png rsvg tiff x11 xml wmf zlib DISTCHECK_CONFIG_FLAGS 'CFLAGS=-g -O2' 'CPPFLAGS=' 'LDFLAGS=' --disable-deprecated --with-quantum-depth=16 --with-umem=no --with-autotrace=no --with-dps=no --with-fpx=no --with-gslib=no --with-fontpath= --with-gs-font-dir=/usr/share/fonts/type1/gsfonts EXEC-PREFIX /usr HOST i686-pc-linux-gnu LDFLAGS -L/usr/lib -L/usr/lib/X11 LIB_VERSION 0x660 LIB_VERSION_NUMBER 6,6,0,4 LIBS -lMagickCore -llcms -ltiff -lfreetype -ljpeg -llqr-1 -lglib-2.0 -lfontconfig -lXext -lSM -lICE -lX11 -lXt -lbz2 -lz -lm -lgomp -lpthread -lltdl NAME ImageMagick PCFLAGS -fopenmp PREFIX /usr QuantumDepth 16 RELEASE_DATE 2010-11-16 VERSION 6.6.0 WEBSITE http://www.imagemagick.org# `awk` is very good at parsing the output of `lsmod`
lsmod | awk 'BEGIN{print "digraph lsmod {"}; NR!=1&&NF==4{printf("\t%s -> { %s };\n", $1, gensub(",", "", "g", $4))}; END{print "}"}' | dot -Tpng | display -
# sorry, please change `gensub(",", "", "g", $4)` to `gensub(",", " ", "g", $4)`