2

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-
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175

1 Answers1

4

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.

guido
  • 8,481
  • 1
  • 20
  • 28