User Tools

Site Tools


tutorials:bash_scripting:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorials:bash_scripting:start [2012/02/24 17:23] rmilestutorials:bash_scripting:start [2017/10/12 21:58] (current) – external edit 127.0.0.1
Line 1: Line 1:
-**1. Bash Scripting By Example**+**Bash Scripting By Example**
  
 I have never found it easy to learn something new without either a having need to do so or an opportunity for practical application. I have never found it easy to learn something new without either a having need to do so or an opportunity for practical application.
Line 5: Line 5:
 No matter how many times I read bash scripting manuals and tutorials it was all just a bunch of hello worlds and loops that count to ten. Nothing much stuck until I had something that I wanted to do. No matter how many times I read bash scripting manuals and tutorials it was all just a bunch of hello worlds and loops that count to ten. Nothing much stuck until I had something that I wanted to do.
  
-It was then that I began learning, remembering what I learned and appreciating how useful bash scripting can be.+It was then that I began learning, remembering what I learned and appreciating how useful bash scripting could be.
  
-There are any number of bash scripting references available I do not intend to write another nor do I presume to be an expert at bash scripting. I learned what I know by working through other folk's scripts and then filling in the blanks from the man pages and the net.+There are any number of bash scripting references availableI do not intend to write another. Nor do I presume to be an expert at bash scripting. I learned what I know by working through other folk's scripts and then filling in the blanks from the man pages and the net.
  
 In the following sections I will present scripts that I have written, explain how they work and in so doing perhaps provide the uninitiated with enough of an understanding of bash scripting to inspire them to open up an editor and get their hands dirty.  In the following sections I will present scripts that I have written, explain how they work and in so doing perhaps provide the uninitiated with enough of an understanding of bash scripting to inspire them to open up an editor and get their hands dirty. 
  
-All the scripts I present in this series work. Feel free to copy them, run them on your machine and have a play at modifying them to see what happens. Any text editor will do. I use //geany// when workin GUIi and //mcedit// (because I'm lazy) when I am working CLI. Both of these editors support syntax highlighting which is very helpful when reading and editing scripts. If you are using KDE try using //kate//.+All the scripts I present in this series work. Feel free to copy them, run them on your machine and have a play at modifying them to see what happens. Any text editor will do. I use //geany// when working GUI and //mcedit// (because I'm lazy) when I am working CLI. Both of these editors support syntax highlighting which is very helpful when reading and editing scripts. If you are using KDE try using //kate//.
  
-You will have to make your script executable. Use //chmod +x [scriptname]//. You can test your script using the command //bash -n [scriptname]//.+You will have to make your scripts executable. Use //chmod +x [scriptname]//. You can test your scripts using the command //bash -n [scriptname]//.
  
 I keep my scripts in ///usr/local/bin// but often save them into ///home/~[somewhere]// when writing them. If I want to run the script I'm working on and it isn't in my //PATH// I usually //cd// into the directory and run the script as //./[scriptname]//. I keep my scripts in ///usr/local/bin// but often save them into ///home/~[somewhere]// when writing them. If I want to run the script I'm working on and it isn't in my //PATH// I usually //cd// into the directory and run the script as //./[scriptname]//.
  
-I suggest that these articles be read in order as each article will assume that the reader understands what has been introduced in the previous article(s). I will explain only what is required to understand how the scripts work. For further information check the man pages, online resources, etc. +You can test a script for errors without running it with the command //bash -n [scriptname]//
 + 
 +I suggest that these articles be read in order as each article will assume that the reader understands what has been introduced in the previous article(s). I will explain only what is required to understand how a script works. For further information check the man pages, online resources, etc. 
  
 ---- ----
Line 23: Line 25:
  
 Rick Miles Rick Miles
-24/02/2012+ 
 +24 Feb, 2012 
tutorials/bash_scripting/start.1330064604.txt.gz · Last modified: 2017/10/12 21:58 (external edit)