How do you create script files in Ubuntu like .bat files in Windows? I want to place a list of commands in a script file and be able to run it as and when required.
How do you create script files in Ubuntu like .bat files in Windows? I want to place a list of commands in a script file and be able to run it as and when required.
google shell scripting.
In linux you basically have a choice of ksh, bash, or csh (there are other shells but those are the major ones).
Registered Linux User: 482377
MacBook (1,1) - OS X Leopard
ASUS P5LD2 - Core 2 Duo 3.0GHz - 2GB Corsair RAM - Nvidia 8800GT - Ubuntu 9.04 / Windows 7 Professional
they are .sh files
run them with a:
Code:./foo.sh
Rocking Lucid Lynx on AMD Phenom IV 9750 with 6GB DDR2 6400 Ram, Nvidia 9800GTX
Create a new file with the following contents
This is the most basic script with 3 commands..Code:#!/bin/sh `command` `command` `command`
Save the file to script.sh and then do
You can now execute it withCode:chmod 755 script.sh
Bash and other shell language have a fairly rich programming environment, so you can do quite a lot more than MS BATCH files..Code:./script.sh
Registered Linux User #446796
Registered Ubuntu User #13489
To get started create a file with a name of x.sh (you can replace the x with whatever you want.). Open it in gedit, and for the first line type
Then you can type in whatever script code you want (pretty much the same thing you type into the terminal. You'll have to read some tutorials if you want to do more complex scripting.Code:#!/bin/bash
Save the file, close gedit and right click on the x.sh icon. Go to "Properties" and then to the Permissions tab.
Check the Execute: box.
Now you can double click on it and it'll give you a chooice of opening in the terminal.
All of this process has terminal equivalents, but you can figure those out later.
Thanks everyone.
Bookmarks