pixel: (losers: jensen OK)
pixel ([personal profile] pixel) wrote in [community profile] linux4all 2010-10-20 11:55 pm (UTC)

Heya, I wasn't ignoring you, I totally get that scripting and command line are intimidating to the less experienced. I had hoped I could write up something simple and quick by way of explanation but it kept getting longer...and longer. So I apologize that I can't walk you through this step by step but I will provide the basic steps for creating a bash script, and if you're interested google should help you get the rest of the way.

Basic concepts:
A script - A script is a list of commands for the computer, written in one of (a good number of) the scripting languages, the code above is written for the bash shell. It is simply a text file, you can edit them with programs such as gedit, nano, vim or emacs. Do not edit them with word processors (like Open Office.)

Permissions - If you've been running ubuntu/linux for a while you might have encountered the concept of permissions, every file, every directory, EVERYTHING on the system has information about that file or directory that describes who may do what with the file or directory. Basically, there are 3 ways to work with a file, you can Read the file (look at it), Write to the file (change it) and Execute the file (it's a file that can be run as a small program.) That's not 100% accurate and I'm sure somebody will say so, but it's enough to get you started. In the case of a bash script, we need to tell the computer that this is an executable file, so it needs to have eXecute permission. That can be changed using the graphical file browser or on the command line.

Steps to using the code I pasted above to make a bash script:
1. Create the file
2. Cut and paste the code above into the empty file
3. Save the file, remember it's name and location
4. Change the permissions on the file to make it executable.
5. Run the file to test and make sure it works.
(6. ....PROFIT!!)

That's it, really, seriously :)
I wish I could be more detailed, but if you're looking to learn, google is your new best friend :D

LinuxCommand.org:
http://www.linuxcommand.org/

Advanced Bash-Scripting Guide:
http://www.tldp.org/LDP/abs/html/
(which says advanced, but what they really mean is 'very detailed')

Good luck, and let us know any new tips or tricks you learn.

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org