Some may be aware that NetTuts+ recently explained how many simple command-line tools can be used to greatly simplify web design tasks. One of which, the use of the tool grep, warrants further analysis.
Firstly, what is grep? It is a unix command line tool that stands for ‘global regular expression print’. I practice, it is used to hunt down a particularly string of characters, and return (print) the results.
How is this useful for web designers? I hear you all ask. Imagine you are working on a project, and remember a string of code that you wrote a while back that would work wonders in your current page. You cannot, for the life of you, remember where the code was written, or even when. You spend hours hunting around on your hard drive and Google and still cannot find the elusive code. You give up. Sound familiar?
Here is where grep can come in extremely useful. By powering up the application ‘Terminal’ (under Utilities in Mac OS X and under the main program menu in Linux) you get a shell prompting a command input. You initiate grep and the arguments that you desire. For example:
$> grep -iR madeUpFunction ./
Would search the current directory for any file that contains the string madeUpFunction and return you the name and location of the elusive file…
To say that this use of grep is only the tip of the iceberg is an understatement, grep is a wholly powerful tool that has been improving and expanding since the inauguration of UNIX in the early days of computing. For example, it can conduct searches that span multiple drives, pipe the output to a printer, even generate reports and documents based on criteria for you. Check out NetTuts+ for more information.