Bash programming - Introduction: verschil tussen versies

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
Regel 26: Regel 26:
 
* https://www.google.com/search?q=learning+programming+bash+from+scratch
 
* https://www.google.com/search?q=learning+programming+bash+from+scratch
  
== Stuff I get energy from ==
+
== 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

Versie van 30 jan 2023 09:58

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

Specifc & personal things

  • ln: To make shortcuts on the Desktop to whatever I often use
  • Man pages. E.g., man ln
  • Associative arrays

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