[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fsuk-manchester] Follow-up: MFS Meeting. Tue, 16 July "Chat on Programm
From: |
Michael Dorrington |
Subject: |
[Fsuk-manchester] Follow-up: MFS Meeting. Tue, 16 July "Chat on Programming" |
Date: |
Tue, 13 Aug 2019 18:25:09 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux i686 on x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 |
On 12/07/2019 09:00, Michael Dorrington wrote:
> * Event: Manchester Free Software's July Meeting
> * What: Chat on Programming
Hopefully the meeting helped people at least get an appreciation of
programming.
If you can type commands on the command line and use a text editor then
you can create a shell script.
In the simplest, you can just put the commands in a text file and run
them by doing:
bash your_file_with_commands
This is assuming you want bash to run the commands.
If you want things a bit more self-contained then add this as the first
line of the file:
#!/bin/bash
and make the file executable by "chmod'ing" the file:
chmod --changes u+x -- your_file_with_commands
Now you can do:
./your_file_with_commands
And if the script's directory is in your PATH then you can just type:
your_file_with_commands
Bash contains the ability to use variables, to do conditional branching
('if / then / elif / else / fi' and '[ ] / test'), loops, regex, arrays,
associative arrays (yes!) and so on. Bash has had features continually
added to it which means some documentation on Bash programming doesn't
use the new features and non-updated installs of Bash might not have
certain features.
Some exercises:
1. What happens if the script is executable but doesn't have a #! line
at the top?
2. What could you have instead of /bin/bash in the #! line?
M.
--
FSF member #9429
http://www.fsf.org/register_form?referrer=9429
http://www.fsf.org/about
"The Free Software Foundation (FSF) is a nonprofit with a worldwide
mission to promote computer user freedom and to defend the rights of all
free software users."
signature.asc
Description: OpenPGP digital signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fsuk-manchester] Follow-up: MFS Meeting. Tue, 16 July "Chat on Programming",
Michael Dorrington <=