The Unix Tools Are Your Friends

Diomidis Spinellis

IF, ON MY WAY TO EXILE ON A DESERT ISLAND, I had to choose between an IDE and the Unix toolchest, I’d pick the Unix tools without a second thought. Here are the reasons why you should become proficient with Unix tools.

First, IDEs target specific languages, while Unix tools can work with anything that appears in textual form. In today’s development environment, where new languages and notations spring up every year, learning to work in the Unix way is an investment that will pay off time and again.

Furthermore, while IDEs offer just the commands their developers conceived, with Unix tools you can perform any task you can imagine. Think of them as (classic pre-Bionicle) Lego blocks: you create your own commands simply by combining the small but versatile Unix tools. For instance, the following sequence is a text-based implementation of Cunningham’s signature analysis—a sequence of each file’s semicolons, braces, and quotes, which can reveal a lot about the file’s contents:

    for i in *.java; do
echo -n "$i: "
sed 's/[^"{};]//g' $i | tr -d '\n'
echo done

In addition, each IDE operation you learn is specific to that given task—for instance, adding a new step in a project’s debug build configuration. By con- trast, sharpening your Unix tool skills makes you more effective at any task. As an example, I’ve employed the sed tool used in the preceding command sequence to morph a project’s build for cross-compiling on multiple processor architectures.

176 97 Things Every Programmer Should Know



Unix tools were developed in an age when a multiuser computer had 128KB of RAM. The ingenuity that went into their design means that nowadays they can handle huge data sets extremely efficiently. Most tools work like filters, processing just a single line at the time, meaning that there is no upper limit in the amount of data they can handle. You want to search for the number of edits stored in the half-terabyte English Wikipedia dump? A simple invocation of

grep ‘’ | wc –l

will give you the answer without sweat. If you find a command sequence gen- erally useful, you can easily package it into a shell script, using some uniquely powerful programming constructs, such as piping data into loops and condi- tionals. Even more impressively, Unix commands executing as pipelines, like the preceding one, will naturally distribute their load among the many pro- cessing units of modern multicore CPUs.

The small-is-beautiful provenance and open source implementations of the Unix tools make them ubiquitously available, even on resource-constrained platforms, like my set-top media player or DSL router. Such devices are unlikely to offer a powerful graphical user interface, but they often include the BusyBox application, which provides the most commonly used tools. And if you are developing on Windows, the Cygwin environment offers you all imag- inable Unix tools, both as executables and in source code form.

Finally, if none of the available tools matches your needs, it’s very easy to extend the world of the Unix tools. Just write a program (in any language you fancy) that plays by a few simple rules: your program should perform just a single task; it should read data as text lines from its standard input; and it should dis- play its results unadorned by headers and other noise on its standard output. Parameters affecting the tool’s operation are given in the command line. Fol- low these rules, and “yours is the Earth and everything that’s in it.”

最新文章

  1. ASP.NET WebApi OWIN 实现 OAuth 2.0
  2. python网络编程-socket
  3. android小技巧(一)
  4. Web软件安全攻击
  5. CloudSim样例分析
  6. Codeforces Round #382 (Div. 2) 解题报告
  7. UVa 1607 (二分) Gates
  8. 继承Animation
  9. We're Hiring A Software Tester
  10. thinkphp 杂乱笔记(1)
  11. org.springframework.web.context.ContextLoaderListener 转
  12. Linux系统相关
  13. Core Data使用之一(Swift): 保存
  14. babel入门基础
  15. 2017年最受欢迎的UI框架
  16. POJ2398【判断点在直线哪一侧+二分查找区间】
  17. 生物分子gene
  18. python--装饰器(附偏函数、断言)
  19. php 多进程
  20. vs 2010 :类型化数据集DataSet应用

热门文章

  1. 【LeetCode】Reverse digits of an integer
  2. hdu 1932(spfa)
  3. 对json同属性字段压缩
  4. [BZOJ2553][BeiJing2011]禁忌 dp+AC自动机+矩阵快速幂
  5. C++的Public.lib(Public.dll) : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
  6. [orangehrm] 安装问题集合
  7. centos6.5 phpmyadmin 您应升级到 MySQL 5.5.0 或更高版本
  8. 转:mysql group by 用法解析(详细)
  9. [ARC100]E:Or Plus Max(FZT)
  10. 6.3(java学习笔记)缓冲流