Thank you for the video. Probably one of the best ones I've seen so far. However, it's not a good idea executing the script while logged in as root for /var/log. There is a much safer alternative which is logging files right where the universal updater script is as user. Other than that, keep up the great work.
Knowing about data streams is very important because sometimes some programs have very unexpected behavior regarding them. A very good example of this is the tool for creating menus "dialog", which outputs collected data to standard error by default.
The reason I find this video series so insightful is because it provides real-world examples of how and why you'd use the scripts/commands. Most other bash scripting tutorials show you every permutation of commands and parameters without any useful context.
Thank you so much for your time and great tutorial. I have only a question: why is it written in the update script like: "if [ $? -ne 0 ] ...." instead of "if [ $? -eq 2 ] ....."? What would be the difference?
The difference is that in the first case where the check is for "$? -ne 0" you will get the error message printed on ANY error code other than 0, even 3 and 4 and basically every other exit code that is possible. In the second case with the check for "$? -eq 2" you will only see the error message printed when the actual error code is 2. Most programs have different error codes for different errors. For example there "ls" command returns either 1 or 2 as an error code depending on the error type. I hope this explains it a bit better. To summarize again, you want the message to appear no matter the actual error code is a long as its not the success code which is 0.
Thanks a lot Jay, just a question, when you re-write the universal update script with the three variables do you actually create two new files (the updater.log and the updater_errors.log) ? Or do they already exist in the system ? Because I thought that in order to create a file you need the touch command 😅 thanks !
Great examples to understand stout and stderr, and how to redirect them to file. Unfortunately, this concept cannot be easily used for piping stderr to grep, for example. I find that extremely strange.
So, now the penny has dropped. Those libraries for log management like Winston on JS use data streams to redirect the console output to a file? Why did I take so much time to realize this? I knew Data streams, before this bash course, when i was learning coding with python(first language), and thought that was only useful for command line utilities, but now, with a little more knowledge, i can see so many use cases for this.
I think you are confusing things. 0 is exit code for succesful commands, and !=0 is exit code for unsuccesful commands. 1 and 2, on the other hand, is the data stream code used to represent standar output and err, which can be independent to exit codes. That is, you can have something with standar errs, but the command can be run succesfully. An example would be sudo apt install notexist1 notexists2 notexist3 htop. This will output some standar errs, as there is no package notexists, but apt will still be able to succesfully run this command, as htop can be installed, and this part will be print as standar output. So the command itself is succesfull, despite printing some (not all) standard errs. Another example is the one with "find" in the video. The command did not fail, so exit code is 0. But, a bit of the information printed was standar errs. In short, command was succesful (exit code 0), despite there being some standar errs (data stream code 2). Note: Take my interpretation with a grain of salt.
Been using Linux for about 15 years, and this is the best tutorial on scripting I have ever seen. Excellent work, Jay.
The best study for someone with ADHD! I learn so much, so quick, it's crazy! Thank you so much Jay 🙏
I’m a junior in college and have never been taught this. This explains so much. Thanks Jay you dah man🤘🏼🤘🏼
This is by far the best bash scripting tutorial. Thanks a bunch for the free knowledge.
Thanks!
I feel like I'm learning Linux the right way from your guide. Thanks for sharing your Linux Expertise.
Thank you for the video. Probably one of the best ones I've seen so far.
However, it's not a good idea executing the script while logged in as root for /var/log. There is a much safer alternative which is logging files right where the universal updater script is as user. Other than that, keep up the great work.
23:00 that is soo cool :D
Thank you sir keep growing
Knowing about data streams is very important because sometimes some programs have very unexpected behavior regarding them. A very good example of this is the tool for creating menus "dialog", which outputs collected data to standard error by default.
Thanks
I am having so much fun with this series! Thank you Jay
Wow! You made the entire bash scripting look facile. Thank you Jay 🤝
I've paid money for longer less helpful programming sessions. Thanks for the information and tutorials!! You're great at this!!!
The reason I find this video series so insightful is because it provides real-world examples of how and why you'd use the scripts/commands.
Most other bash scripting tutorials show you every permutation of commands and parameters without any useful context.
Excelent work
You are a very good teacher
You are a master !
it s entertaining watching your videos, extremly skilled.
Thank you
Thank you so much for your time and great tutorial. I have only a question: why is it written in the update script like: "if [ $? -ne 0 ] ...." instead of "if [ $? -eq 2 ] ....."? What would be the difference?
The difference is that in the first case where the check is for "$? -ne 0" you will get the error message printed on ANY error code other than 0, even 3 and 4 and basically every other exit code that is possible. In the second case with the check for "$? -eq 2" you will only see the error message printed when the actual error code is 2. Most programs have different error codes for different errors. For example there "ls" command returns either 1 or 2 as an error code depending on the error type. I hope this explains it a bit better. To summarize again, you want the message to appear no matter the actual error code is a long as its not the success code which is 0.
Very useful tutorial
Thanks a lot Jay, just a question, when you re-write the universal update script with the three variables do you actually create two new files (the updater.log and the updater_errors.log) ? Or do they already exist in the system ? Because I thought that in order to create a file you need the touch command 😅 thanks !
good video. I even bought a faster Internet to watch it in better quality.
thank you for teaching us.
Thanks
Great examples to understand stout and stderr, and how to redirect them to file. Unfortunately, this concept cannot be easily used for piping stderr to grep, for example. I find that extremely strange.
So, now the penny has dropped.
Those libraries for log management like Winston on JS use data streams to redirect the console output to a file? Why did I take so much time to realize this?
I knew Data streams, before this bash course, when i was learning coding with python(first language), and thought that was only useful for command line utilities, but now, with a little more knowledge, i can see so many use cases for this.
👍Thanks!
what stands for tail -f? tail is just last rows.. but what is -f
Хороший материал
You might want to add `--noconfirm` flag for pacman to run silently.
me who already added -y before you said lol 😂
i thought 0> would show it :c
can anyone tell what is this "apt does not have a stable CLI interface. Use with caution in scripts" ?
If 1 is the exit code for standard output then how come we get exit code 0 after echo.
I think you are confusing things. 0 is exit code for succesful commands, and !=0 is exit code for unsuccesful commands. 1 and 2, on the other hand, is the data stream code used to represent standar output and err, which can be independent to exit codes.
That is, you can have something with standar errs, but the command can be run succesfully.
An example would be sudo apt install notexist1 notexists2 notexist3 htop. This will output some standar errs, as there is no package notexists, but apt will still be able to succesfully run this command, as htop can be installed, and this part will be print as standar output. So the command itself is succesfull, despite printing some (not all) standard errs.
Another example is the one with "find" in the video. The command did not fail, so exit code is 0. But, a bit of the information printed was standar errs. In short, command was succesful (exit code 0), despite there being some standar errs (data stream code 2).
Note: Take my interpretation with a grain of salt.
@@MrUwU-dj7js Thanks for such illustrated explanation.
Debug script with root permissions... hmm..smart
Note :
Cmd 1 > file1.txt is equivalent to Cmd > file1.txt
&> means sending both stdin and stderr
1000th ✌
everything in /dev/null is never seen from or heard from again...