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.”

The Unix Tools Are Your Friends的更多相关文章

  1. Cross-platform Tools

    MinGW和Cygwin都解决了C++跨平台交叉编译的问题,使Linux下的程序在Windows上编译运行成为可能. MinGW给习惯在Linux上开发的人员在windows上提供了一套类似的工具集: ...

  2. 让 ASP.NET vNext 在 Mac OS 中飞呀飞。。。

    写在前面 阅读目录: 娓娓道来 Install ASP.NET vNext Command Line Tools 安装 Homebrew 使用 Homebrew,安装 KVM Install Subl ...

  3. 生成lua的静态库.动态库.lua.exe和luac.exe

    前些日子准备学习下关于lua coroutine更为强大的功能,然而发现根据lua 5.1.4版本来运行一段代码的话也会导致 "lua: attempt to yield across me ...

  4. VS2012使用Git并连接到osc@git

    1.下载GitExtensions并安装 在http://sourceforge.net/projects/gitextensions/files/latest/download 下载 安装时请注意 ...

  5. 【Docker 在 windows 10 / windows 8 下安装】

    步骤: 1. 下载: a.https://github.com/boot2docker/windows-installer/releases 下载一个 windows 客户端: 安装时建议勾选:Boo ...

  6. Nginx初学者指南

    Starting, Stopping, and Reloading Configuration To start nginx, run the executable file. Once nginx ...

  7. Django开发博客- 部署

    安装Git Git是一个被大量程序员使用的”版本控制系统”.此软件可以跟踪任何时间文件的改变,这样你以后可以随时召回某个特定版本. windows系统下面可以下载git-scm安装.除了第5步”Adj ...

  8. 命令行工具cmder

    1.下载地址 http://bliker.github.io/cmder/ 分为两个版本:mini版和Full版 2.快捷命令配置: 比如,快速启动canssandra/redis数据库服务和查询工具 ...

  9. Beginner’s Guide(开始者向导)

    This guide gives a basic introduction to nginx and describes some simple tasks that can be done with ...

随机推荐

  1. ubuntu 16.04 qtcreator 闪退

    当用QtCreator 进行代码自动补全时,比如编写ros代码,ROS_INFO时候就会出现闪退,后面按照 http://doc.qt.io/qtcreator/creator-clang-codem ...

  2. [libgdx游戏开发教程]使用Libgdx进行游戏开发(2)-游戏框架搭建

    让我们抛开理论开始code吧. 入口类CanyonBunnyMain的代码: package com.packtpub.libgdx.canyonbunny; import com.badlogic. ...

  3. luoguP2296 寻找道路

    因为是出边与终点直接或间接相连,所以将边反向,从终边开始,将所有终边能到达的点都打上标记因为是最短路,所以不需要处理重边和自环,于是再跑最短路就好题目关键:路径上的所有点的出边所指向的点都直接或间接与 ...

  4. 27、Django实战第27天:全局搜索功能开发

    当我们选择其中一个类别(公开课,课程讲师,授课老师),输入搜索内容,点击搜索后会跳转到相应的列表页中进行展示 我们输入的内容作为参数keyword传入后台 搜索"公开课" 当课程中 ...

  5. 3、Django实战第3天:数据建模

    users modesl.py设计 UserProfile 用户信息 EmailVerifyRecord 验证码 Banner 轮播图 之前我们生成了Django默认的数据表,里面有张表示auth-u ...

  6. 金融应用,计算将来的学费 Exercise05_07

    /** * @author 冰樱梦 * 时间:2018年下半年 * 题目:金融应用,计算将来的学费 * */ public class Exercise05_07 { public static vo ...

  7. TZOJ 数据结构实验:单链表元素插入

    描述 实现函数CreateHeader用于创建空链表,实现Insert函数并调用它完成带头节点链表的创建. 部分代码已经给出,请补充完整,提交时请勿包含已经给出的代码. void PrintLinkL ...

  8. Eclipse / Pycharm | 使用过程中的一些问题笔记

    最近有比较多的用到这两款工具,其中也遇到一些问题,知道了一些快捷键 快捷键什么的这里就不讲了,去网上搜搜,经常使用下,自然就熟悉了 主要记录一下我遇到的几个问题 文章目录 Pycharm出现的部分快捷 ...

  9. iOS键盘监听事件

    1.注册键盘通知事件 NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; // 键盘将出现事件监听 [center ...

  10. 网络采集软件核心技术剖析系列(6)---将任意博主的全部博文下载到SQLite数据库中并通过Webbrower显示(将之前的内容综合到一起)

    一 本系列随笔目录及本节代码下载 自己开发的豆约翰博客备份专家软件工具问世3年多以来,深受广大博客写作和阅读爱好者的喜爱.同时也不乏一些技术爱好者咨询我,这个软件里面各种实用的功能是如何实现的. 该软 ...