Diff for "AnalyzingData/Primer_ShellScripting" - Meg Wiki
location: Diff for "AnalyzingData/Primer_ShellScripting"
Differences between revisions 2 and 3
Revision 2 as of 2010-06-11 11:13:19
Size: 911
Editor: YaaraErez
Comment:
Revision 3 as of 2010-06-11 11:20:45
Size: 1088
Editor: YaaraErez
Comment:
Deletions are marked like this. Additions are marked like this.
Line 15: Line 15:
Nothing can stop you now! This is boring. You want to be more flexible. In many scripts, you want to execute the same command(s) for a number of different subjects. For this, there is the "for" loop:

attachment:LoopScript.jpg

You should already know how to set-up and use a [http://imaging.mrc-cbu.cam.ac.uk/imaging/UsingVNC VNC viewer], and have some basic knowledge of [http://www.ee.surrey.ac.uk/Teaching/Unix/ Linux or Unix].

For example, you probably know commands such as ls, cd, pwd or mkdir which you usually execute in a command window:

attachment:FirstCommands.jpg

If you want to display text on the screen, you can use the "echo" command. If you want to display this text very often (don't ask for the reason), then you can write it in a script.

Open a new file (e.g. using the text editor "nedit", put "#!/bin/sh" at the top (so the file knows it's a script and how to interpret the following commands), and add the command you would like execute.

Save the file. You have to make the file executable by changing the permissions ("chmod" command).

attachment:FirstScript.jpg

This is boring. You want to be more flexible. In many scripts, you want to execute the same command(s) for a number of different subjects. For this, there is the "for" loop:

attachment:LoopScript.jpg

CbuMeg: AnalyzingData/Primer_ShellScripting (last edited 2013-03-08 10:02:29 by localhost)