Command line

Working through the command line, i.e. working with a text-only interface from a terminal, is a very powerful way to do precise and flexible data manipulation. Unfortunately, the command line has fallen out of use for a wide variety of reasons, non of which having to do with it being in any way inferior or more difficult. As a matter of fact, it is easier to do certain operations, in particular producing automated and reproducible processes, and it is the preferred method for a large group of scientists (not only programmers) and even just regular, computer “power users”.

In the following sections, I will gather some tricks that make it easier for you to work with command line tools like CQP. A terminal only handles text in- and output so mouse functionality is limited. Some keys and key combinations also migh show unexpected behavior.

CQP cheatsheet and tutorials

Here is a nice cheat sheet with most commands you need working with CQP. You don’t have to learn any commands by heart, but know where to find them.

There is also a YouTube video series on how to use CQP on our server. Some parts of it, especially the setup instructions, are not up to date anymore, but it is still a great resource.

There is also a written guide that includes a few more functions and might help if you don’t speak German.

This YouTube channel also hosts a tutorial on how to do collostruction analysis, which we will talk about in week 12.

Copy & Paste

ctrl + c and ctrl + v have different meanings in most terminals. ctrl + c e.g. cancels the current process. Depending on your terminal program, you might want to try the following things (not an exhaustive list).

  • ctrl + shift + c (copy) and ctrl + shift + v (paste)
  • Middle mouse button (in Linux and macOS)
  • Windows only: right click, (both copy and paste)
  • Mac only: Cmd + Shift + c to enter copy mode

Another quirk of a terminal is that everything is text, even the prompt and other things you would normally consider part of the interface. Sometimes you want to select only the output of something. You can do so by holding down ctrl or option + Cmd while selecting with the mouse to select a block.

Other useful commands and shortcuts

  • ctrl + c cancel current process. Can be used to stop a slow query
  • CQP: ctrl + l clears the screen (type clear outside CQP)
  • CQP: info find information on the corpus, including available tags, structural attributes, How to Cite …
  • CQP: info or concordance view: / (forward slash) search, n for next result; great for finding the right tag

Colors

It might sound weird, but the default color scheme in a terminal is probably one of the main reasons people find working in the command line scary. Black on white or white on black (blue for Powershell) are ugly, hurt your eyes, and can make focussing for longer time periods difficult. My suggestion is, therefore, to switch this to a low contrast color scheme. Light gray text on a darker gray background is what I personally can work with best.

  • Windows Powershell: right click on the top bar → properties → colors
  • Windows Terminal: See here
  • Putty: color menu is right on the left on the start screen
  • macOS: right click on “Terminal” in the panel → properties → profiles

There is a whole parallel universe of people for whom terminal color schemes are an art form (check out this subreddit). Since CQP does not produce colored output (yet), it is unfortunately not too useful for us.

The shell

The shell is what is running in your terminal and interprets your commands. Through the shell, you have access to a lot of useful tools like ls, grep, cut, all of which you can combine in so-called pipelines. More on this coming soon.