MozFest 2013: Journalists should command the command line

Journalists who want to learn more technology often jump into HTML, CSS and Javascript. Those are great places to start (as Knight Lab and others have written before), but if you want to maximize the potential of your computer, one of the first things you should learn is the command line!

Some quick background: Regular computer users access the computer via a graphical user interface (GUI). This interface allows you to interact with the machine using a mouse and images on your screen to make the computer do what you want.

But you can also navigate and control your computer by using text-based commands on something called the command line. By firing up a program called Terminal (at least on Mac), you can enter text commands and navigate through your computer.

Noah Veltman, a 2013 Knight-Mozilla Fellow at BBC News, led a session at MozFest called “Solve A Murder Mystery on the Command Line." The game involved a folder of .txt files with thousands of lines. To solve the murder mystery, we had to search through the files using the command line to pull out specific phrases.

After channeling my inner detective during the session, it occurred to me that I didn’t know how to use the command line until a couple months after I started programming. Once I started using the command line, I understood my machine much more and learned programming more quickly.

I talked to Noah after the session to gather a couple more ideas on why journalists should learn the command line.

It makes it easier to work with text data


When it comes to working with text data, especially large and messy files, command line tools are your best friends. Datasets might come to you as .csv files from a government agency, or as .txt files from local companies. To navigate through these files or to extract useful and interesting information the command line helps you do so quickly.

You might wonder, Why not just open Excel or Access to look at the data? While Excel works great with a 50MB file, the software isn't nearly as nimble with a 5GB file. By way of example, Illinois School Board School Scorecard files include more than 10,000 columns and precious little metadata to explain what’s contained in each one. The big and complicated files are very hard to comprehend and it turns out to be a challenge to analyze the data.

With the command line, a couple basic commands will help you analyze text data:

cat filename
The cat command allows you to read the files. It opens a text file and prints the content in terminal. Type the word cat followed by a space and the name of the file.

grep option pattern filename
The grep command is used to search text for specific patterns. For example if I would like to search for the word “corgi” in a file called corgi.txt. I would enter the command:
grep “corgi” corgi.txt.

head option filename
The head command reads the first few lines of any files. For example if I would like to look at the first 20 lines of a file I would enter the command:
head -n 20 corgi.txt

It lets you use tools built just for journalists


Tons of tools built for journalists involve using the command line, if only during the installation phase. You’ll often hear that “software package X is exactly what you need" for a particular task, but then you wind up looking at a GitHub repo where you learn that installation of that software involves various command line operations.

csvkit, for example, converts files to .csv and helps you to clean up and standardize data. Using csvkit and the command line, you can filter a .csv down to a subset of columns, search and filter rows, join various .csv files, etc. These tasks are done by simple commands like in2csv, csvcut csvgrep, etc. As opposed to copying and pasting from one Excel file to another, these short commands allow you to clean and organize your data in a matter of seconds.

It’s a gateway to full scripting languages


Noah referred to command line tools as “a gateway drug” to actually learning a full scripting language like Python. Once you begin to feel comfortable with a few basic commands, you can begin to combine them in all sorts of ways to get what you need even if you cannot write a custom data processing script.

There are plenty of reasons to learn the command line. Hopefully your curiosity is sparked. If it is, click the links below to learn more:

http://cli.learncodethehardway.org/book/
http://www.youtube.com/watch?v=Fzn6jbaw6O0&feature=related
http://www.linuxjournal.com/content/downloading-entire-web-site-wget
http://csvkit.readthedocs.org/en/latest/

About the author

KK Rebecca Lai

Undergraduate Fellow

Latest Posts

  • AR Face Filters: How Do They Work and How Are They Changing Us?

    This video explains the mechanisms behind how selfie filters change our digital images and then how this might psychologically affect us. To make this video, I researched “Snapchat Dysmorphia” and also looked for the technical understanding of selfie filters. Before creating this video, I made a selfie filter for the Knight Lab using Spark AR to get a sense of how face deformation would work in Instagram selfie filters. The animation workflow for me looked...

    Continue Reading

  • 9 Important VR Experiences for Journalists to See

    In an era where social media outpaces print newspapers in the U.S. by a whopping 4% (Pew Research Center, 2018), there is much to be said about the role of interactive media technology in minimizing this gap between technology and storytelling. How can publications, and the journalists within them, use interactive media technology to re-engage with this lost audience? And why might this shift towards digital storytelling, such as VR, be more valuable for journalism than...

    Continue Reading

  • 7 Reflections on SRCCON:Productthe first conference for “product thinkers” in media

    On Feb. 8 in Philadelphia, I was lucky to be one of about 150 participants at SRCCON:Product, the first conference for “product thinkers” in media. A few reflections on what I saw and learned: 1. A quarter of a century into the digital age, we are finally figuring out how to build media products In 1995, I was named the first online director for The Miami Herald, with responsibility for launching the “Internet edition” of...

    Continue Reading

  • Building a Community for VR and AR Storytelling

    In 2016 we founded the Device Lab to provide a hub for the exploration of AR/VR storytelling on campus. In addition to providing access to these technologies for Medill and the wider Northwestern community, we’ve also pursued a wide variety of research and experimental content development projects. We’ve built WebVR timelines of feminist history and looked into the inner workings of ambisonic audio. We’ve built virtual coral reefs and prototyped an AR experience setting interviews...

    Continue Reading

  • A Brief Introduction to NewsgamesCan video games be used to tell the news?

    When the Financial Times released The Uber Game in 2017, the game immediately gained widespread popularity with more than 360,000 visits, rising up the ranks as the paper’s most popular interactive piece of the year. David Blood, the game’s lead developer, said that the average time spent on the page was about 20 minutes, which was substantially longer than what most Financial Times interactives tend to receive, according to Blood. The Uber Game was so successful that the Financial...

    Continue Reading

  • With the 25th CAR Conference upon us, let’s recall the first oneWhen the Web was young, data journalism pioneers gathered in Raleigh

    For a few days in October 1993, if you were interested in journalism and technology, Raleigh, North Carolina was the place you had to be. The first Computer-Assisted Reporting Conference offered by Investigative Reporters & Editors brought more than 400 journalists to Raleigh for 3½ days of panels, demos and hands-on lessons in how to use computers to find stories in data. That seminal event will be commemorated this week at the 25th CAR Conference, which...

    Continue Reading

Storytelling Tools

We build easy-to-use tools that can help you tell better stories.

View More