Saturday, October 24, 2015

Linux: Finding Hams from a particular state in a list of Callsigns

Recently I wanted to extract the Texas hams from a long list of callsigns. As there were over several hundred calls in the list (and I am lazy), some automation was needed. I did it with a little Bash script and the Callsign Server at the University of Arkansas:

The callsign server at UALR can report the address the FCC has for hams in its database.

[Note: This script assumes you are familiar with Linux at the command line level and are running the Bash shell or similar]

First place the list of callsigns you need to search into a file with each call on a single line. Here is an example (add a few calls if you like):


The list can be quite long. Save this as a file called:


Here is the Bash call-list.cmd script:

# call-list.cmd by cln – WB5BKL 10/2015
for CALL in `cat ./call-list`
echo -e "\n"
echo "\$CALL="$CALL
echo -e "\n"
sleep 1
wget -O $CALL.htm$CALL

Copy and save this script as call-list.cmd. Make the script executable:

chmod +x call-list.cmd

Then place it in the same directory as the call-list file. I would strongly suggest an directory empty except for these two files.

Then execute the call-list.cmd:


You should find a series of files have been created in the directory with the suffix: .htm  For example:


Then execute the following command (assuming you want only the calls that were in Texas:

grep -l "TX" *.htm

and you will see a list of the calls that have TX as part of their address field.

Or you could do this:

grep -l "TX" *.htm > TXcalls.txt

and the file TXcalls.txt will contain a list of the files that had TX as a part of the address. This list could then easily be edited to remover the “.htm” extension – and you have your list of hams in Texas.

Of course, you could use this to look for other states, or even calls that had “Extra” or “CT” or “John” as a part of their listing. Lots of possibilities here.

cln - Nick

No comments:

Post a Comment