new using scripts

Hello, trying to make simple script that says hello world,
can someone help me out please

echo 'Hello world'

thanks for quick reply.
do I have to create a file cuz it comes out :

bash: !/bin/sh: event not found


Yes you put those two lines in a file, make it executable with:

chmod u+x myfirstscript

then you can run it with:


For a beginner you can think of the contents of scripts as what you would type in at the terminal. The first line beginning with #! is special, it tells the system what kind of script it is, in this case a shell script.

You might like to search for tutorials on writing shell scripts, and come back with questions here about things you don’t understand in the tutorials. It’s rather slow if you expect to learn only by question and answer on this forum.

It allso means that you did not type the # when you entered this in a terminal.

Take care that the # is also in the file you are going to create.

On 03/06/10 09:46, mkdataflow wrote:
> Hello, trying to make simple script that says hello world,
> can someone help me out please
> thanks,
> mk

For shell scripts:

For Python scripts:

For Perl scripts:

For PHP scripts:

And so on, and so on. ‘… tutorial’ in any search site gives plenty of hits to try.



here are a few web-sites that might help you get started:

Barry Nichols

If you don’t want to make a script executable, you can run it with:

sh "scriptname"

Anything you type on the command line can be pretty much put in a script file (usually ending in .sh, but doesn’t have to) for repeative use or automation. If you put the command(s) in a script the first line has to be #!/bin/bash or #!/bin/sh, and you need to change the permissions of the script. Checkout the book at Linux Command Org and you’ll learn a lot really fast. There’s even a wiki on shebang :slight_smile:

If you want to learn bash, the best online sources are:

  1. Linux Command Org. Download his book.
  2. The Linux Documentation Project Guides. There’s a Beginner and Advanced.

Both of these were already mentioned. But they are so good, they should be mentioned again. You won’t need anything else, well, except the man page (man bash) :slight_smile:

Additional tips:

  1. man -k “subject”; Where subject is something you want to find out more about. It could be program name, daemon, config file, etc. In Konqueror, you can type “man:/” in the address bar, if you want a more gui experience for reading man pages.

  2. Always look in the package directory for documentation. The bash package directory has an additional reference: /usr/share/doc/packages/bash/bashref.html, not to mention the man page in html format.

  3. type - this will return: " is a shell builtin"; type - this will return: " is a shell keyword"; type clear - this will return: “clear is /usr/bin/clear”. whereis clear - will then tell you which library contains the external command. If the results are builtin or shell keyword you know you need to look in the bash manpage.

Wow, nice thread I’ve been looking for a good tutorial about scripting. :slight_smile: I’m Bookmarking right now!!

For this special “programming problem”, this site might be helpful

The Hello World Collection


very informative thread.

how would i know which script i need to write on Novell SUSE Linux ver 10

#!/bin/bash or #!/bin/sh

ls -l /bin/{bash,sh}

lookinginfo wrote:
> how would i know which script i need to write on Novell SUSE Linux ver
> 10
> #!/bin/bash or #!/bin/sh

can’t you use either?
look in your /bin and see if you have both…i bet you do…here, my
/bin/sh is a link to /bin/bash

by the way, you do know that SLE_ 10 and 11 is serviced over at (but you are very welcome to be here, just recognize
that most everyone here has never even run SLE_ 10)…


When you have looked up what that #!.. means (when not, look in Wikipedia for ‘shebang’ (Unix), you would know that it is the interpreter that must interprete the script. There are many interpreters, but here we talk about shells. There are many shells also: Posix shell, Bourne shell, Korn shell, C-SHell, Bourne-Again SHell and more.

Until now two shells where mentioned in this thread:
. bash (Bourne-Again SHell)
. sh (Posix shell)
These are different. Even when (as allready was indicated) they point to the same executable file. There were already threads here about problems originating in the fact that somebody used bash constructs and then let it interprete as* sh*.

I advise you to use* bash*, it is the standar shell used in Linux. I would advice sh if you have to program for other Unix systems also, it makes your progam more portable.