A Quick Introduction to Unix/Editing Text
Pico: the simplest editor
So far we have been using built-in Unix commands issued directly at the shell prompt. To take things a little further we really need to be able to create and edit text files. There are a large number of different editors available for Unix users, among them
We are going to use pico because it is very widely installed on Unix systems and is by far the easiest to use for the beginner.
Pico is a terminal based program and when you start it the terminal switches from the prompt to the pico editing screen. So, if you type
you should see
where at the bottom of the screen you see two rows of Pico command help. This on-screen help is what makes Pico attractive to beginners. Although the commands are unfamiliar (and perhaps even idiosyncratic) you have reminders always to-hand. Pico doesn't have the sophisticated text manipulation functions or flexibility that other Unix editors have, but we don't need that yet.
You can start Pico with a filename as well, typing, for example
Notice that I gave the file the extension .sh to remind me - and Unix - that it is a script file (of which more later). The screen will look just the same if the file doesn't exist when you start but if the file does already exist then its contents will be displayed on screen. You enter text directly at the Pico cursor and issue commands with combinations of the control key and a character (the character part is not case sensitive). If you issue a command and wish to cancel it you use ^c. You can move about your file with the arrow keys.
Some Pico behaviour will take a little getting used to.
|^ alone||begins to mark text as selected. Now move the cursor with the arrow keys and text is highlighted. The selection ends at the current cursor position.|
|^k||cuts selected text|
|^u||pastes the last cut|
|^i||creates a tab/indent|
|^o||saves the file when you have finished editing|
Pico does have a little more functionality than this (although not much!) but this is enough for current purposes. Before you go on to creating scripts, use the Pico editor to create a text file of your own making sure to practise these few commands.
- Shells and subshells
- Directory Structure
- Files and Processes
- Listing Files and Directories
- Exercises 1
- Creating Directories
- Creating Files
- Changing Directories
- Special Directories
- Exercises 2
- Copying Files
- Moving Files
- Deleting Files
- Exercises 3
- Searching Text Files
- More grep examples
- Permissions on Files and Directories
- Editing Text
- Exercises 4
- My First Shell Script
- Job Control
- Environment Variables