From 21f0424e48c682e903b577d39ed5da90a87dcd66 Mon Sep 17 00:00:00 2001 From: ronny abraham Date: Thu, 12 Dec 2024 18:30:39 +0200 Subject: [PATCH] updates --- _subsections/lesson-01.org | 1 - _subsections/lesson-02.org | 76 ++++++++++++++++++++++++++++---------- 2 files changed, 56 insertions(+), 21 deletions(-) diff --git a/_subsections/lesson-01.org b/_subsections/lesson-01.org index b9c96a1..4640115 100644 --- a/_subsections/lesson-01.org +++ b/_subsections/lesson-01.org @@ -7,7 +7,6 @@ #+attr_html: :class links - [[../toc.org][TOC | Missing Semester]] - [[https://www.youtube.com/playlist?list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J][Playlist: Missing Semester]] -- current: https://youtu.be/Z56Jmr9Z34Q?si=t9wQkGXDznscDtNH&t=1217 *** timestamps :PROPERTIES: diff --git a/_subsections/lesson-02.org b/_subsections/lesson-02.org index d2d9172..df952aa 100644 --- a/_subsections/lesson-02.org +++ b/_subsections/lesson-02.org @@ -14,22 +14,22 @@ :END: #+attr_html: :class playlist -1. [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=54s][control flow functions]] -2. [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=227s][sequential execution]] -3. [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=425s][standard input]] -4. [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=444s][error code]] -5. [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=517s][logical operators]] -6. [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=603s][concatenate commands]] -7. [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=645s][common substitution]] -8. [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=675s][process substitution]] -9. [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=935s][comparison operator]] -10. [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=1173s][curly braces]] -11. [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=1359s][python script]] -12. [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=1707s][man command]] -13. [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2175s][finding files]] -14. [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2190s][grep]] -15. [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2573s][fuzzy finder]] -16. [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2649s][history substring search]] ++ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=54s][00:54 - control flow functions]] ++ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=227s][03:47 - sequential execution]] ++ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=425s][07:05 - standard input]] *current* ++ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=444s][07:24 - error code]] ++ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=517s][08:37 - logical operators]] ++ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=603s][10:03 - concatenate commands]] ++ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=645s][10:45 - common substitution]] ++ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=675s][11:15 - process substitution]] ++ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=935s][15:35 - comparison operator]] ++ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=1173s][19:33 - curly braces]] ++ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=1359s][22:39 - python script]] ++ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=1707s][28:27 - man command]] ++ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2175s][36:15 - finding files]] ++ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2190s][36:30 - grep]] ++ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2573s][42:53 - fuzzy finder]] ++ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2649s][44:09 - history substring search]] * Notes @@ -42,16 +42,15 @@ #+end_src - this doesn't: - #+begin_src bash foo = bar echo $foo #+end_src - the output of that will be - =zsh: command not found: foo= + - the output of that will be + =zsh: command not found: foo= - - what happens in the above example is that we are effectively calling the "foo" program with the arguments: "=" and "bar" + - what happens in the above example is that we are effectively calling the "foo" program with the arguments: "=" and "bar" *** quotes - you can use double or single quotes to print a value @@ -76,3 +75,40 @@ will return: =Value is $foo= +** sequential execution + +*** bash functions +- mcd.sh +#+begin_src bash +mcd() { + mkdir -p "$1" + cd "$1" + } +#+end_src bash + +- creates a function that can be executed after loading + - $1 is a global variable referring to the first parameter + +*** source +- using source mcd.sh + =source mcd.sh= + +- then carry out the function + =mcd testdir= + +- this will create a new directory and cd into it as per the definied functioned + +*** variables +- $0 -- name of the script we are currently in + - if you run this in the shell it will display 'bash' +- $1->$9 -- the first through ninth argument given to a script +- $? -- the last error message +- $_ --- last argument of the previous call + +- !! -- recreates the last call with it's arguments + - use with sudo if you found your call needed a sudo and you don't feel like retyping it again + + #+begin_src bash + ls -lah + sudo !! + #+end_src