Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How can I plot the output of this command line with GNUPlot? What should the diagram script look like?

I want a histogram.

wget -O - -o /dev/null http://www.stackoverflow.com/ |
cat | cat | sed "s/</\n</g" |
grep '<\/\{0,1\}[a-zA-Z][a-zA-Z\:\._\-]\{0,\}' |
cut -f 2 -d"<" | cut -f 1 -d">" | cut -f 1 -d" " |
sed "s/\//\\n/g" |
sort | uniq -c |
tail -n +2 |
cut -c5-
share|improve this question
Since the first invocation of sed(1) seems wrong, and you didn't mention what kind of data you want to plot, it is difficult to answer your question. :) –  cinsk Dec 20 '11 at 0:15
@cinsk how is that sed wrong? It inserts a newline before each <. Correctly. –  Kevin Dec 20 '11 at 0:37
I don't remember how to work gnuplot, I just use the help facility every time I want it. –  dmckee Dec 20 '11 at 1:00
add comment

1 Answer

up vote 5 down vote accepted

This should help you out. Write data to file (changed cut -c5- to cut -c4- because it was deleting the first digit):

wget -O - -o /dev/null http://www.stackoverflow.com/ | cat | sed "s/</\n</g" | grep '<\/\{0,1\}[a-zA-Z][a-zA-Z\:\._\-]\{0,\}' | cut -f 2 -d"<" | cut -f 1 -d">" | cut -f 1 -d" " | sed "s/\//\\n/g" | sort | uniq -c | tail -n +2 | cut -c4- > mydata.txt

Create myplot.dem (some custom initialization added here, change it as you like it):

set style data histogram
set style fill solid border -1
set log y
set boxwidth 0.9
set term png
set tics out nomirror
set xtics rotate by -45
set output "histogram.png"
plot "mydata.txt" using 1:xticlabels(2)

and finally:

gnuplot myplot.dem

creates your plot "histogram.png" in current directory.

share|improve this answer
Thank you very much! –  Robert Sundström Dec 20 '11 at 13:12
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.