Bash programming - Introduction: verschil tussen versies
(Nieuwe pagina aangemaakt met 'How to start programming in Bash, without prior programming experience? And making sure it will be fun? == Basics == * Shebang, script files, make files executabl...') |
|||
(6 tussenliggende versies door dezelfde gebruiker niet weergegeven) | |||
Regel 3: | Regel 3: | ||
== Basics == | == Basics == | ||
− | * Shebang, script files, make files executable, terminal screen | + | * Shebang, script files, make files executable, terminal screen, editor (I use Sublime Text) |
* Display ''Hello, world!'' | * Display ''Hello, world!'' | ||
* Variables (scalars): Assigning & displaying | * Variables (scalars): Assigning & displaying | ||
+ | * Commenting (<code>#</code>) 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>!'' | * 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 | * Comparisons, e.g., check for empty imput and take appropriate actions | ||
Regel 14: | Regel 15: | ||
* Functions | * Functions | ||
* Evaluating commands | * 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: | ||
+ | |||
+ | * <code>ln</code>: To make shortcuts on the Desktop to whatever I often use | ||
+ | * Man pages. E.g., <code>man ln</code> | ||
+ | * Arrays & associative arrays: I use these a lot in translating webshops | ||
+ | * [[Hoofdpagina#WP-CLI | WP-CLI]] | ||
== Explore further yourself == | == Explore further yourself == | ||
Regel 19: | Regel 29: | ||
* https://www.google.com/search?q=learning+programming+bash+from+scratch | * https://www.google.com/search?q=learning+programming+bash+from+scratch | ||
− | == | + | == 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 | * WordPress: Update all prices with one small script | ||
* Remove whitespace around pictures with just one command | * Remove whitespace around pictures with just one command | ||
* Using <code>mmv</code> to update lots of file names at once. | * Using <code>mmv</code> 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 (Bash) | Translate shell]] for translating stuff | ||
+ | * AI (Artificial Intelligence). | ||
== Sources == | == Sources == | ||
+ | |||
* https://dev.to/ahmedmusallam/bash-from-scratch-learn-enough-bash-to-write-your-own-scripts-189f | * https://dev.to/ahmedmusallam/bash-from-scratch-learn-enough-bash-to-write-your-own-scripts-189f | ||
+ | * https://ryanstutorials.net/bash-scripting-tutorial - Good | ||
+ | * https://www.hostinger.com/tutorials/bash-scripting-tutorial - Good | ||
+ | * https://www.freecodecamp.org/news/shell-scripting-crash-course-how-to-write-bash-scripts-in-linux/ - Good, but maybe too detailed | ||
+ | * https://linuxconfig.org/bash-scripting-tutorial-for-beginners - Bit too ambitious for a beginner |
Huidige versie van 6 feb 2023 om 16:41
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).
Sources
- https://dev.to/ahmedmusallam/bash-from-scratch-learn-enough-bash-to-write-your-own-scripts-189f
- https://ryanstutorials.net/bash-scripting-tutorial - Good
- https://www.hostinger.com/tutorials/bash-scripting-tutorial - Good
- https://www.freecodecamp.org/news/shell-scripting-crash-course-how-to-write-bash-scripts-in-linux/ - Good, but maybe too detailed
- https://linuxconfig.org/bash-scripting-tutorial-for-beginners - Bit too ambitious for a beginner