Linux Crash Course - Data Streams (stdin, stdout & stderr)

Поделиться
HTML-код
  • Опубликовано: 16 май 2024
  • In this episode of Linux Crash Course, we'll go over data streams. Specifically, Standard Output (stdout), Standard Input (stdin), and Standard Error (stderr). We'll also take a look at how to redirect specific data streams, so you can easily separate errors from output.
    Brand LPI Linux Essentials Course Available
    Check out the new course on Udemy! ➜ learnlinux.link/lpi-course
    5% discount on LPI exam vouchers
    After you finish Jay's new course, get 5% off an LPI exam voucher here:
    ➜ learnlinux.link/lpi-voucher
    Check out the Linux Shop
    In the official shop, you'll find Shirts, hats, stickers, bags and more!
    ➜ merch.learnlinux.tv
    Become a Patron
    Show your support for Learn Linux TV on Patreon and get access to exclusive perks!
    ➜ learnlinux.link/patron
    Become a Channel Member
    Show your support for Learn Linux TV here on RUclips and get access to exclusive perks!
    ➜ learnlinux.link/member
    Mastering Ubuntu Server: 4th Edition
    Jay's latest book covers everything you need to know in order to master Ubuntu Server. It's available here:
    ➜ ubuntuserverbook.com
    Linux Gear and Kits
    Check out Jay's choice of hardware products, audio/video equipment, and more.
    ➜ learnlinux.link/amazon
    Grab an awesome Pi-powered KVM
    Support Learn Linux TV and grab yourself a TinyPilot KVM here:
    ➜ learnlinux.link/tinypilot
    Note: Royalties and/or commission is earned from each of the above links
    Time Codes
    00:00 - Intro
    00:41 - Quick note regarding input/output
    01:17 - The three data streams (standard input, standard output, and standard error)
    03:06 - Example of Standard Error (stderr)
    03:47 - Using the echo command to find the return code
    05:54 - Example of both standard output and standard error from one command
    07:47 - Splitting standard output and standard error
    09:06 - Number designations for stdin, stdout, and stderr
    10:24 - Sending stdout and stderr to different files
    Full Courses from Learn Linux TV
    • Linux Essentials Certification Workshop ➜ learnlinux.link/lpi-course
    • Linux Crash Course series ➜ linux.video/cc
    • Learn how to use tmux ➜ linux.video/tmux
    • Learn how to use vim ➜ linux.video/vim
    • Bash Scripting Series ➜ linux.video/bash
    • Proxmox VE Cluster Full Course ➜ linux.video/pve
    • Learn Ansible ➜ linux.video/ansible
    Linux-related Podcasts
    • Enterprise Linux Security ➜ enterpriselinuxsecurity.show
    • The Homelab Show ➜ thehomelab.show
    Learn Linux TV on the Web
    • Main site ➜ www.learnlinux.tv
    • Community ➜ community.learnlinux.tv
    • Enterprise Linux Security Podcast ➜ enterpriselinuxsecurity.show
    • The Homelab Show Podcast ➜ thehomelab.show
    • Content Ethics ➜ www.learnlinux.tv/content-ethics
    • Request Assistance ➜ www.learnlinux.tv/request-ass...
    Disclaimer
    Learn Linux TV provides technical content that will hopefully be helpful to you and teach you something new. However, this content is provided without any warranty (expressed or implied). Learn Linux TV is not responsible for any damages that may arise from any use of this content. The person viewing Learn Linux TV's content is expected to follow their best judgement and to make their best decisions while working with any related technology. Always make sure you have written permission before working with any infrastructure. Also, be sure that you're compliant with all company rules, change control procedures, and local laws.
  • НаукаНаука

Комментарии • 72

  • @RayBitton
    @RayBitton 2 года назад +18

    And that's why I'm proud of myself...
    I never think I know everything.
    I'm a linux administrator as part of my day job and I think I got a good amount of experience with the command line but reading the title of the video made me think "Maybe I'll learn something new about stdout and stderr".
    I wasn't wrong.
    "find /etc -type f > ~/results.txt 2> ~/errors.txt"
    Never knew or thought about splitting the streams.
    THANK YOU FOR THAT!
    So useful.

  • @satysin630
    @satysin630 2 года назад +24

    When I am introducing someone to the command line this is my go to example of where the command line interface still wins out over a graphical program. The beauty is the application(s) being used don't need to be changed in any way as it is the shell that handles it all for you (providing the applications output to stdout and stderr properly).
    I once worked with someone that was very "ugh I hate the command line, it's not the 1980s anymore, GUI is always better" so I asked then to do just what you did. Output valid results to one file and errors to another. The only way he could do it was manually and by actually looking then copy/paste the errors to a separate file as none of his graphical tools could filter output (they would just save everything to a single file) so would require the application itself be updated to include such functionality.
    It didn't totally win him over but it at least shut him up as he knew I would always bring that example up if he ever went on a "GUI is better" rant again 😂Truth is you use the right tool for the job, sometimes that *is* a GUI application but sometimes it's a CLI one so knowing how to best use the tools available is important.
    Great video 👍

  • @sgt.chutney5206
    @sgt.chutney5206 2 года назад +3

    Another awesome video Jay, you are a great teacher. I would love to see a beginners guide to regular expressions. Thanks!

  • @clblanchard08
    @clblanchard08 2 года назад +4

    I've been using linux for years and never really understood this. Thank you so much!

    • @andymann6061
      @andymann6061 2 года назад

      Same here - I was grappling with it just a couple of days ago, but Jay explains it perfectly.

  • @Andy.N-_-
    @Andy.N-_- 2 года назад

    Love these vids that teach me some of the basics we keep forgetting well done and thank you

  • @tilla455
    @tilla455 Год назад

    Great tutorial again. Thank you! Your videos have helped me with work on a daily bases

  • @TheRexhim
    @TheRexhim 2 месяца назад

    Thank you! I needed clarification on this!

  • @DL-xf3ur
    @DL-xf3ur Год назад

    Awesome as always Jay! Thanks!

  • @piusvictor8780
    @piusvictor8780 2 года назад

    You are teaching style is amazing brother ✨✨✨ one love from Tanzania, thanks for sharing, your tutorial are highly recommended to anyone interested with learning Linux.

  • @anthonyverzosa1292
    @anthonyverzosa1292 5 месяцев назад

    Thank you very much for this wonderful lesson.

  • @itay1207
    @itay1207 Год назад

    YOUR EXPELTAION WAS SO CLEAR AND GOOD.WAS EASY TO UNDERSTAND !THANKS

  • @davehodsdon3533
    @davehodsdon3533 Год назад

    Great information. Thank you, Jay.

  • @polliluiz
    @polliluiz Год назад

    You’re amazing Jay. Thank you for all of your videos. It’s really the best

  • @dfurmans
    @dfurmans 2 года назад

    Thanks for a great clarification!

  • @greob
    @greob 2 года назад +14

    I was expecting you to talk about how to output both stdout AND stderr to a file.
    For anyone wondering we do it like this: find /etc -type f > combined.txt 2>&1

    • @jyvben1520
      @jyvben1520 2 года назад +1

      not working on raspberry pi, "> combined.txt 2>&1" does work.

    • @greob
      @greob 2 года назад +1

      @@jyvben1520 yeah it's possible some shells parse it differently, and I suppose that is the correct way of doing it. I'll edit my original comment.

  • @jorgepadron2426
    @jorgepadron2426 2 года назад

    Excellent, as always!

  • @perminusgaita
    @perminusgaita 6 месяцев назад

    This is amazing🔥

  • @codeai4178
    @codeai4178 10 месяцев назад

    I can't thank you enough for these videos sir.

  • @13thravenpurple94
    @13thravenpurple94 Год назад

    Great work! Thank you

  • @nicolasrenard2551
    @nicolasrenard2551 2 года назад

    Very good video. More details about standard input would be great.

  • @ugola1
    @ugola1 3 месяца назад

    Amazing!

  • @deedoi
    @deedoi 5 месяцев назад

    Nice and clear explain, thank you so much! :))

  • @OscarCedano
    @OscarCedano 5 месяцев назад

    Awesome! Thank u!

  • @HighReallyWhy
    @HighReallyWhy 3 месяца назад

    Thank you >> GREAT TUTORIAL

  • @dakhamed
    @dakhamed 11 месяцев назад

    Thank you so much

  • @jacekkieblesz655
    @jacekkieblesz655 Год назад

    Very good explanation ,really very good teacher

  • @egysnet
    @egysnet 2 года назад

    Although I know most of what you're talking about, I enjoy watching the explanation

  • @udayarpandey3937
    @udayarpandey3937 2 года назад

    Hello Jay, can you make a series based on real-time project you have worked with? That would be really great.
    Thank you.

  • @inestimable7276
    @inestimable7276 Год назад

    Thank you so so much !!!!

  • @SrRunsis
    @SrRunsis 2 года назад

    magnificent videoo!! thxx

  • @mohammadmurtazanaiemy7503
    @mohammadmurtazanaiemy7503 Год назад

    Its useful thank you so much

  • @withanaarachchi956
    @withanaarachchi956 2 года назад

    Many thanks.

  • @yazou123
    @yazou123 2 года назад

    Thanks a lot

  • @evodefense
    @evodefense 4 месяца назад

    thx

  • @paulojsilva__
    @paulojsilva__ 5 месяцев назад +1

    You miss 2>&1 to redirect both output (stdout) and errors (stderr) to same file like find /etc/ -type f > ~/all_results.txt 2>&1

  • @devbites77
    @devbites77 2 года назад +10

    Great vid as usual. Any chance of a video on bash special params: $*, $@, $#, $$, $!, $?, $-, $_ And how they are used?

  • @kwangee
    @kwangee 10 месяцев назад

    This topic is seriously useful 👏.
    I always saw and don't understand 1> 2> in GitHub repo sh file 😂

  • @jyvben1520
    @jyvben1520 2 года назад

    Could do your testing while using a live cd, nothing to break (do not mount the installed system)
    expect a follow up about what todo with $? in scripts ...

  • @nitinnamdev5627
    @nitinnamdev5627 2 года назад

    I am very interested in Linux. while seeing the > /dev/null i am very confusing what is it ? Now i am fully understand . Thank you

  • @gurudayal5743
    @gurudayal5743 2 года назад

    as you mentioned about writing a script for sending an email for error or success. How do we do that ,where can I find such script? kindly help

  • @kellychristus2496
    @kellychristus2496 4 месяца назад

    Is there any way to catch stdin 0 and place it into a file like stdout 1 and stderr 2?

  • @surkewrasoul4711
    @surkewrasoul4711 Год назад

    This man is smart. He knows some physics.

  • @louiseantwine3569
    @louiseantwine3569 11 месяцев назад

    0:38 how do I add a splash screen

  • @paulojr1384
    @paulojr1384 Год назад

  • @TariqMehmood-1307
    @TariqMehmood-1307 2 года назад

    I am your subscriber / fan from Pakistan 🇵🇰

  • @GooogleGoglee
    @GooogleGoglee 2 года назад

    And what if you want to send stout and stderr at the same time to the same file without repeating the file twice in the command line?

    • @BigBlueMotors
      @BigBlueMotors 2 года назад

      See NJUL's comment.

    • @themedleb
      @themedleb 2 года назад +2

      find /etc -type f > combined.txt 2>&1

  • @jonemiller9603
    @jonemiller9603 Год назад

    Does Linode have training modules ?

    • @LearnLinuxTV
      @LearnLinuxTV  Год назад

      There's some being created right now, some of which by me :) Stay tuned...

    • @jonemiller9603
      @jonemiller9603 Год назад

      @@LearnLinuxTV got it. Do you know what other websites have training modules ?

  • @krishnapillai6157
    @krishnapillai6157 2 года назад

    Jai shri ram sir i like your indepth technical skills. 🚩🇮🇳

  • @MuhammadNadeem-hi1ik
    @MuhammadNadeem-hi1ik Год назад

    $ Thanks

  • @marcin2x4
    @marcin2x4 Год назад

    I noticed that running `find /etc/ -type f 2> /dev/null` still prompts 1 when running `echo $?`
    As always, awsome content! These tutorials are on my top-list!

  • @aleksic1234
    @aleksic1234 2 года назад +1

    im one of the first

  • @themistoclesnelson2163
    @themistoclesnelson2163 Год назад

    Comment

  • @JorgeEscobarMX
    @JorgeEscobarMX 2 года назад +10

    Great video, but why disable dislikes? -- Update: nevermind I see youtube did it.

    • @patricknelson
      @patricknelson 2 года назад +3

      Yeah it’s really detrimental for people looking for high quality content like this. For example, I can still see dislikes right now (due to gradual rollout), and this video has only 1 dislike with 412 likes.

    • @fullstack_journey
      @fullstack_journey 2 года назад

      it's because RUclips is run by incompetent fools

    • @goodboy8833
      @goodboy8833 2 года назад

      @@fullstack_journey Like u

    • @wambamcamcam
      @wambamcamcam Год назад

      They did it because of the massive amount of dislikes from a Biden speech... Js..

  • @MaheshKumar-bg5re
    @MaheshKumar-bg5re 3 месяца назад

    Are you doing meditation? i saw Buddha statue ...

  • @AbdulRafay-vi6hz
    @AbdulRafay-vi6hz 2 года назад

    Hey, Love your topic but here is an advice for you, Don't get mad, it's up to you to take it.
    Please don't make you videos like a lecture in a class room, make then light and make it fun for other to learn, Don't be a teacher from year 1890, be cool.

    • @AriannaEuryaleMusic
      @AriannaEuryaleMusic 2 года назад +2

      I actually like Jay the way he is, direct and to the point (No clowning around) plus he is very clear, to me is really fun... Perhaps you might like the arrogance of Luke Smith videos... I don't.

    • @AbdulRafay-vi6hz
      @AbdulRafay-vi6hz 2 года назад

      @@AriannaEuryaleMusic never heard of Luke Smith... let's see...No you are not getting the point... he's been to formal....I never said that I don't like this content or I didn't understand the point... he's good in explaining but All I am saying is that he should be a little less formal, Read a script in way you are are talking to a person in front of you not like a robot.

    • @AriannaEuryaleMusic
      @AriannaEuryaleMusic 2 года назад +1

      @@AbdulRafay-vi6hz Why "Should he"? You don't have the right to say how Jay "should" run his channel Just because you don't like the format, and you are the one missing the Point, This channel is about LEARNING, if you don't like it, just go somewhere else, there are many Linux channels, and YOU SHOULD be thankful, This Channel is teaching all this stuff for free. I repeat, if you don't like it, don't watch this channel.

    • @AbdulRafay-vi6hz
      @AbdulRafay-vi6hz 2 года назад

      @@AriannaEuryaleMusic chill out...mad man.... It's social Media and it's my right to give advice it's up to Him to take or not . I'm forcing him... second the advice is for Jay not for you..so buzz off.

    • @AriannaEuryaleMusic
      @AriannaEuryaleMusic 2 года назад +2

      ​@@AbdulRafay-vi6hz I repeat, if you don't like it, GTFOH. period.