The power of a GNU-empowered terminal 

My father needed some help. The task at hand was to send invitation SMSes to about 200 mobile phone numbers.

The mobile numbers were in a text file like an address book with several irrelevant fields. The mobile numbers were stored in the form of ‘Mobile:<number>\n’ . We wanted only the mobile numbers, so I did a

cat <phonebookfile> | grep Mobile

and there – all the phone numbers were separated. Next, I wanted to throw away the Mobile: part and retain only the number. That was done using awk:

cat <phonebookfile> | grep Mobile | awk “BEGIN{ FS = ‘:’ } { print $2 } > listofnumbers

Next, we wanted to send an SMS to each of these numbers. I typed the SMS into some file (call it smsfile) and then connected my mobile phone to the computer and then did a

for i in `cat listofnumbers`; do cat smsfile | gnokii –sendsms $i >> gnokii-out 2>> gnokii-error; echo $i >> finishednos; done;

And that’s it! We had some trouble inbetween, and sending failed starting from the Nth number in the file. So what we repeated the command with tail -n <num> instead of cat on listofnumbers, to send it to the remaining.

That’s the power of BASH + GNU on the command line.