Tutorial on shell scripts for saving searches

Very often, it is convenient to save the various searches that you run on coded corpora or coding strings with so-called shell scripts.

When you type commands at the keyboard in the ordinary way, you are giving commands to the shell one by one. When you run (a.k.a. execute) a shell script, you give the commands in the script to the shell in a batch.

I've put together two sample shell scripts for you to edit and tailor to your own purposes. The first script is intended to introduce you to shell scripts; it simply executes a batch of grep searches, outputting the results to the screen or to a file. In principle, you could type the results from a script like this one into a spreadsheet program by hand. Don't do this, though, because it is both time-consuming and error-prone. Instead, use a script of the second type, which generates output that is suitable for importing into a spreadsheet program directly.


Executing a batch of grep commands

Generating input to a spreadsheet program

Once you understand how shell scripts like batchGrep work, you can further expedite your work by writing shell scripts to generate files that can be directly imported into a spreadsheet program. You should use this second type of shell script because it will make your work both faster and more accurate.