Bash programming - Introduction: verschil tussen versies
Regel 23: | Regel 23: | ||
* Man pages. E.g., <code>man ln</code> | * Man pages. E.g., <code>man ln</code> | ||
* Arrays & associative arrays: I use these a lot in translating webshops | * Arrays & associative arrays: I use these a lot in translating webshops | ||
− | * [[WP-CLI]] | + | * [[Hoofdpagina#WP-CLI | WP-CLI]] |
== Explore further yourself == | == Explore further yourself == |
Versie van 30 jan 2023 10:04
How to start programming in Bash, without prior programming experience? And making sure it will be fun?
Basics
- Shebang, script files, make files executable, terminal screen, editor (I use Sublime Text)
- Display Hello, world!
- Variables (scalars): Assigning & displaying
- Commenting (
#
) and documenting in a structured way - Receiving user input & processing it - E.g.: Ask the user for his/her name and displaying something like Hello, <name>!
- Comparisons, e.g., check for empty imput and take appropriate actions
- Flow control: Loops. E.g.: Display the numbers from 1 to 100 on the screen; With a step function; Backwards
- Pipelining. E.g.
ls > tmp.txt
- Grep; Pipelining
- Passing arguments to scripts
- Functions
- Evaluating commands
Personal basic
Stuff that is relevant in an early stage for me personally right now (2023.01), but may not be relevant for others:
ln
: To make shortcuts on the Desktop to whatever I often use- Man pages. E.g.,
man ln
- Arrays & associative arrays: I use these a lot in translating webshops
- WP-CLI
Explore further yourself
Things I get energy from
I love the power of automating stuff, and doing things in a breeze that for non-technical people would be a hell of a job. E.g.:
- WordPress: Update all prices with one small script
- Remove whitespace around pictures with just one command
- Using
mmv
to update lots of file names at once.
Why I like this? Somewhere in 2022, I did a personality test focused on primary motives and one of my main motives was confirmed to be individualism (as if I didn't know that already): I very much want to be authentic and independent, and automating is a great tool for this. Additionally, it's a selling point and even a production factor: Thanks to a growing library of functions, I can do more and more tasks under conditions (time, price) that non-programmers cannot compete with.
Some other technologies that fit this pattern - I'm not familiar with all of these:
- Pipelining: Using the output of one command as the input for another command
- Regular expressions: Advanced pattern matching - Can be very powerful in all kind of situations
- APIs (Application Programming Interfaces)
- Webservices. Example: Using Translate shell for translating stuff
- AI (Artificial Intelligence).