Nano! Creating, Changing and Saving Files

In this post we created files using the echo command, now we want something more complex.  The answer is to use an editor.  Now this isn’t an editor like the guy who works for a newspaper, this is a program that lets us create, save, change, and otherwise fiddle with a file.  We’re going to use one called nano.

In the Linux© community, a good way to start an argument is to ask a group of people what the best editor is.  It’s kind of like asking who the best superhero is (I’m told Deadpool. I personally like Iron Man… or even Hawkeye… Black Widow is cool… see what I mean?) or which is better, Marvel or DC?  So we’re not going to talk about best editor, we’re going to start with an easy one.

Alpha:~ computerlamp$ nano

This is what it looks like:

The nano editor

The nano editor

I can type whatever I want into this screen, like this:

Editing with nano

Editing with nano

I can save it with the key combination control-O:

Saving with nano

Saving with nano

I just have to tell it what filename I want.  I’m going to save it as nano.txt.

Then, when I’m done, I’ll exit nano:

Exiting nano

Exiting nano

And now I can create, edit and save a file.  What if I want to edit the file again?

Alpha:~ computerlamp$ nano nano.txt

That brings up that file I just created.

nano has a man page, and it even explains why it’s called nano:

NANO(1)                                                                                NANO(1)

NAME
       nano - Nano's ANOther editor, an enhanced free Pico clone

SYNOPSIS
       nano [OPTIONS] [[+LINE,COLUMN] FILE]...

There’s also help available within nano, if you use the key combination control-G you’ll get a help screen that looks like:

Help within nano

Help within nano

nano is one of the easiest editors to use, which is awesome because we no longer have to rely on echo!  It also creates what are called text files, which means that what  you type in is what you get.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *