Articles tagged “bash”
How to mirror a static copy of the opensource.org website
I currently maintain the italian mirror of the Open Source Initiative web site, and today I realized that the script I wrote some months ago wasn’t doing its job well.. because the CSS files weren’t downloaded at all, causing a rather unpleasant rendering of the site.
To mirror opensource org I’m currently using the plain’ol GNU Wget -r—mirror and so on. While the good’ol wget downloads each page prerequisite defined in the HTML source, it doesn’t support @import CSS rules, and doesn’t download images referenced in CSS with url() rules.
BTW, nothing that can’t be resolved with some regex-fu: that’s why I’m sharing the script I’m currently using to mirror the opensource.org web site, hoping it will generate either a new mirror or some insights on how to do this job better :).
The script: update_opensource_mirror.sh
Enjoy! :)
What does your .bash_history say?
A friend of mine told me that on techie blogs there is a new meme going on: show off the most used commands, starting from shell history:
history | \
awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | \
sort -rn| head -15
I’ve got 20 times the default bash history size (10k lines), so it’ll yield interesting results. I also use the history timestamp feature, so I’ve added a little sed to the code in order to strip timestamps out.
Let’s see:
13:19:50 vjt@voyager:~/code*$* history |
sed 's#^[ 0-9\[\/\:]*\]\([^ ]*\).*#\1#' |
awk '{a[$1]++}END{for(i in a){print a[i] " " i}}' |
sort -rn | head -15
928 l
577 ssh
389 ping
381 cd
300 dig
259 telnet
153 sudo
126 ifconfig
125 whois
113 ps
96 svn
91 cat
73 fg
68 vi
61 ..
yeah, I do a LOT of ls, l is actually ls -alFGs (I’m on Darwin). This list exposes my recent habits, because I’m coding less and managing more (no gcc, no irb, lots of dig & whois). svn is still there, of course ;). ssh means that these results should be aggregated with other histories coming from the other boxes I log on to.. but that’s a topic for anoter post ;).
Which are your results?
Post them here! :D
UPDATE 2008-06-03
As my recent habits are more coding than writing docs, I re-ran the history analysis.. and these are the new results:
1796 l 981 svn 705 ssh 693 cd 666 ping 402 vi 356 ifconfig 352 telnet 321 dig 315 sudo 283 fg 240 grep 188 .. 183 cat 157 ps
UPDATE 2009-02-20
5427 l
4379 git
3128 svn
2812 vi
2105 cd
1408 ping
1392 fg
1328 ssh
935 ifconfig
893 grep
890 sudo
733 rake
653 cat
554 ..
535 ruby
UPDATE 2009-05-24
7374 l
5041 git
3265 vi
3131 svn
2753 cd
1881 ssh
1763 ping
1618 fg
1101 sudo
1100 ifconfig
977 grep
867 cat
767 rake
721 telnet
671 ..
UPDATE 2010-06-01
20517 git
7794 l
1906 cd
1631 rg
1518 vi
1108 rake
1041 cat
1010 ruby
790 sudo
754 fg
676 make
670 script/console
626 rm
496 ping
474 ..
Today's row
05:01:24 vjt@voyager:~/Antani/trunk$ replace(){ sed -e "s|$1|$2|g"
< $3 > ${3}X; mv ${3}X $3; }; egrep -r 'XP_[A-Z_]+[[:space:]]+-?[[
:digit:]]' Headers |ruby -ne "f,m=scan(/(.+):.+(XP_[\w_]+)/).first
;puts '%s %s %s' % [ f, m, 'kXP'<<m.scan(/(_[A-Z])([A-Z]+)/).map {
|a,b| a[1..1]<<b. downcase }.join ]" | while read hdr from to; do
replace $from $to $hdr; for src in `grep -rl $from Sources`; do
replace $from $to $src; done; done


