3

The teacher never explained us anything about unix and bash. He told us something about the history. Then he said how to fill in an IP address in a program called putty, which is the shell we used to work on the server. He basically gave us 7 series of exercises. We also had a book that was pretty useless. I mostly used internet and SO to help myself out, along with the commands I knew from DOS and the man/info pages.

The question is, what is the preferred text editor to make scripts? Internet says any will do but I know only cat. And then, how do I even begin? What I need is a crash course or something. I'm sorry I know this isn't the best kind of question to ask here but it's all I can think of atm. Don't blame me, but please do bash the teacher (pun intended).

4
  • 2
    "I know only cat" Does this mean that you'll be restricted to editors in the terminal? If so, see if nano is available. It doesn't really require learning. Otherwise, use something like gedit on Linux or notepad on Windows. Commented Jun 6, 2012 at 21:05
  • @Hassan Nano should be available. I'll look into it. But we only have the terminal to work with. Commented Jun 6, 2012 at 21:07
  • 1
    Okay then I would definitely use nano. If you're familiar with another one like vim, use it, but nano is going to take you 5 minutes to "learn". Here's a short tutorial: debianadmin.com/nano-editor-tutorials.html Commented Jun 6, 2012 at 21:10
  • @Hassan thanks. I'll take a look at both and see what will be best. Commented Jun 6, 2012 at 21:11

2 Answers 2

5

Try using vi as your text editor. Change to the directory you want your script to be saved in and then type in `vi myScript.sh". This will start the vi text editor. You can type in all your shell commands here.

Here's a link to a vi cheat sheet - http://linuxfordummies.org/tag/vi/

Once your in vi, you can type in one command on each line, you can use enter to move to the next line. After you have your script typed in, press : on the keyboard to open a prompt for vi. Once you have the : (colon) prompt at the bottom of the screen, enter wq for write/quit. This will save myScript.sh to the directory you started in. You should then be able to execute the script just by calling myScript.sh

I hope this helps, best of luck!

Sign up to request clarification or add additional context in comments.

5 Comments

If you have access to something like nano, it may be easier. I mentioned vi here, because basically any Linux/UNIX distribution you are logging into should have vi installed, also it works quite well inside of a putty session.
That's perfect thanks. I like how you actually explained what the colon does. I remember struggling with vi trying to exit, and when the prompt was there how i started messing everyting up. I know I'm a noob at this but it was NEVER explained.
Glad I could help! My first dev job required me to edit shell scripts on a 1994 NCR UNIX system via putty and telnet. Vi was my only hope, I've been using it for 3 years and I still don't know all the shortcuts and commands.
I don't think anybody knows all the vi commands... I've been using it for 15 years and I still learn new commands almost every day!
You need to press the ESC, before typing : Please, update your answer bro)
0

You could use the vi text editor, but it can be a bit tricky if you're starting out. I would try gedit if your using a GNOME environment

1 Comment

uh.. GNOME? Yeah I'll try vim.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.