linux.autostatic.com

Linux Audio Babble

Living in a shell

No comments

Since I started working for my new employer the amount of time I'm spending inside a terminal window is rapidly increasing. And I like it. I'm learning more in a few months than I did in the past 5 years. I'm discovering superhandy commands and utilities that I had never used or even heard of before. Utilities like w, last and the various *stat utilities. And I'm becoming better and better in using utilities that I already know but that always remained hard to grasp simply because I didn't use them extensively. Think of Vim, screen and sed. Or on a lower level, the Bash shell itself.

I'm particularly starting to develop a fondness for Vim. I've worked myself through a complete Vim book and when I finished it I was like, Vim is not arcane at all, it's actually quite simple. It's all about terseness, doing things in the fastest, most efficient way, memorizing the most important commands and forcing myself to use it for things I would normally do in say, gedit. So now I find myself easily copying whole blocks of text, commenting and uncommenting multiple lines with just a few keystrokes, using markers and buffers and browsing faster through files than possible with a mouse.

Currently I'm reading a book on Bash and it already provided me with a lot of new insights and ideas that I could use in my daily work. My scripting skills are a bit feeble so hopefully this book will help me to improve these. Luckily I have great colleagues that are very knowledgeable when it come to things like Bash and Vim so I'm coming along just fine. But I want to be able to purge a Sendmail mail queue filled with spam like I saw one of my colleagues do recently. What he did on top of his head was just amazing:

for i in `ls | grep qfr`; do w=`grep example.org $i | wc -l`; if [ "$w" != "0" ]; \
then echo $i | sed -e 's/^qfr//'; fi;  done | sed -e 's/^/*/' | xargs -n 50000;

This allowed him to create a list of all spam messages which he simply ran through rm. It's no rocket science but I'd really like to be that proficient too. Another colleague of mine is just awesome with regular expressions and Vi. For example, I recently asked him how I could delete all text between parentheses including the parentheses, for example a list of packages I copied from /var/log/apt/history.log, and he immediately replied %s/([^)]*)//g. Yes, I'm blessed that I can work in such an inspiring environment.

Written by Jeremy

Saturday 30 November 2013 om 16:55

No comments

Leave a comment

(optional field)
(optional field)
Remember personal info?
Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.