Understanding Variables on the Linux Command-Line

  Рет қаралды 14,242

Learn Linux TV

Learn Linux TV

Күн бұрын

The Linux Crash Course series here on Learn Linux TV teaches you a valuable Linux-related skill in each and every video. You can watch most episodes in any order, and with over 60 entries in this series (and counting) there's no shortage of Linux Learning! In this episode, Jay will teach you all about shell variables.
Free Bash Scripting Course!
Check out my brand-new Bash scripting series for free right here on KZfaq ➜ linux.video/bash
Thanks to Akamai for sponsoring this video!
Support Learn Linux TV by spinning up your own Linux server on their cloud platform ➜ learnlinux.link/akamai
LPI Linux Essentials Course Available
Check out the new course on Udemy! ➜ learnlinux.link/lpi-course
➜ learnlinux.link/lpi-course
Check out the Linux Shop
In the official shop, you'll find Shirts, hats, stickers, bags and more!
➜ merch.learnlinux.tv
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
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 KZfaq 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:46 - Set up your own Linux server with Akamai! (Sponsor)
01:58 - Revisiting the echo command
02:45 - Creating a variable in Bash
03:11 - Printing the contents of a variable
08:54 - Understanding Environment Variables
12:19 - Capturing the output of a command into a variable
15:22 - Capturing the current date into a variable
Full Courses from Learn Linux TV
• Linux Crash Course series ➜ linux.video/cc
• Learn how to exit 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.
#CloudComputing #DevOps #Linux

Пікірлер: 34
@sidheart8905
@sidheart8905 5 ай бұрын
i am professional with 11 year experience but i still love your all videos and keep watching them daily the way you explain basics... just addicted for learning.
@Akaterial
@Akaterial 4 ай бұрын
Great video. I watched it last month when it was new. It came back to me as I was moving a bunch of files and directories around. Typing out directory names can be tedious even with autocomplete. I used what I learned in this video to create variables of the directory paths. It instantly made things so much easier. I could not only copy things around faster, I could also move around to the directories I stored in variables faster.
@12Q46HPRN
@12Q46HPRN 5 ай бұрын
Outstanding! Thank you so much for your videos. I always learn something from you. I knew quite a bit about shell variables and even the env command. I've used the $(command) before, but more as a script-kiddie (copy/pasting what I've seen others doing online) and never knew that it opened up a sub-shell to run the command within the parentheses. Please keep up the good work!
@lorensims4846
@lorensims4846 5 ай бұрын
Don't sweat the ALL CAPS. Many early computers (and in fact the first typewriter) used only all caps. Using lowercase or mixed-case letters tends to complicate things. Merry Christmas!
@Xenonandplutonium
@Xenonandplutonium 5 ай бұрын
Pretty cool how I was learning about Python variables and you dropped this. This is cool. I feel like I can really get things more organized.
@dylananderson7658
@dylananderson7658 5 ай бұрын
Amazing explanation, thank you!
@zeppelinmexicano
@zeppelinmexicano 3 ай бұрын
It should be interesting to see how this subshell-capture trick will work with some output more sophisticated than "ls" and all that. If it can actually capture htop in any meaningful way it would be handy to grab it for log purposes. Dunno, but there is a lot to test.
@BenChnobli
@BenChnobli 5 ай бұрын
Thanks
@bramfran4326
@bramfran4326 5 ай бұрын
Why do newlines disappear inside the variable at 13:30? That does not seem very consistent, imagine if other things you don't know (obviously not normal characters??) could also disappear.
@IcarusSparry
@IcarusSparry 5 ай бұрын
The newlines are still in the variable, except for the very last one. The problem I have with this video is that you always (except when you don't, but that is very rare) want to use variables inside double quotes. So if our host had used echo "$file_list" we would have seen the output in the way that was expected. To dive a little deeper, if the variable is used outside double quotes then it is split into words, and the echo command outputs each word it is given separated by a space. This also means that multiple spaces and tabs get removed, and then echo puts a single space back. msg="Hello World" echo $msg Hello World echo "$msg" Hello World Bash does have sub-shells, which are created with "(" and ")". The thing that is created with "$(" and ")" is a different concept called "command substitution". Whilst this is clearly an introductory video, I think that with a length of 18 minutes it could also mention arrays. The syntax for them is fairly horrible but they needed to be added in a reasonably backward compatible manner.
@SnowTheParrot
@SnowTheParrot 5 ай бұрын
Another great episode
@brhend
@brhend 5 ай бұрын
Thank you
@juliusmilo5959
@juliusmilo5959 5 ай бұрын
Thank You...
@Shocker99
@Shocker99 5 ай бұрын
6:40 You should have ls'd a directory with something in it for this example.
@adrmantap6508
@adrmantap6508 5 ай бұрын
What ur font name please?,
@TheGeekYT
@TheGeekYT 5 ай бұрын
Thanks!
@mihai6564
@mihai6564 5 ай бұрын
good video
@x91w
@x91w 5 ай бұрын
Is it OK to download say your bash course videos as a reference to use offline? If not where can I purchase a licence?
@ciscornBIG
@ciscornBIG 5 ай бұрын
I've downloaded all learn Linux tv. KZfaq-dl
@pmpartners
@pmpartners 5 ай бұрын
If I want a variable to be available every time I open bash, is there a way to persist them?
@gumse666
@gumse666 5 ай бұрын
If you declare it in .bashrc it will be available in every new terminal session (you have start a new terminal after you add your command to se the variable)
@pmpartners
@pmpartners 5 ай бұрын
@@gumse666 Thank you! I’ll give it a try.
@Shriramkrishnhari
@Shriramkrishnhari 5 ай бұрын
👍
@majstorgile
@majstorgile 5 ай бұрын
👏👏👏
@tanuj05
@tanuj05 5 ай бұрын
Nice video , did not know about sub shell
@ujjawalsinha8968
@ujjawalsinha8968 5 ай бұрын
Why do we call Shell a "Shell". Is it because of the concept of "Sub-Shells"?
@tschorsch
@tschorsch 5 ай бұрын
Because it's a shell around the OS, i.e. the outermost layer that a user interacts with. Shells can be command line or graphical.
@sotecluxan4221
@sotecluxan4221 5 ай бұрын
@suhas_joshi
@suhas_joshi 5 ай бұрын
Sir add some videos with no-ip server setup
@ZubairKhan-vs8fe
@ZubairKhan-vs8fe 5 ай бұрын
Please help. Why does Linux need a command line and a shell. Windows stopped using DOS ages ago
@teecount1
@teecount1 5 ай бұрын
powershell on windows? To answer your question: It is usefull, if you do not want to do things yourself and want to have full control over the system.
@motoryzen
@motoryzen 5 ай бұрын
Need? That depends If a program isn't launching at all or isn't launching correctly ( be it Linux , Mac, or Windows ) you can launch that program via a command prompt or terminal and you can then SEE....WHY. ;) Another scenario = a script that can completely setup and install all programs in your PC if you ever need to do a clean install ...starting over....and in the end..save literally...DAYS of work doing it all manually by hand. Instead...you'll end up doing it manually by hand.....once maybe twice..and make notes into the script. These are just a few of the many good scenarios where a command line and/or shell can be invaluable.
@palodoxaliqua5809
@palodoxaliqua5809 5 ай бұрын
That path-variable had a / at the end. I therefore expected $mydir/hello.txt to have two / before the file name and throw an error because of the invalid path. Seems like linux ignores unnecessary slashes - interesting curiosity.
@theshowmanuk
@theshowmanuk 5 ай бұрын
Thanks
Linux Process Tuning Made Easy: Understanding nice and renice
16:34
Learn Linux TV
Рет қаралды 11 М.
What is $PATH on a Linux Shell? (The Linux Crash Course Series)
21:52
Learn Linux TV
Рет қаралды 30 М.
Dynamic #gadgets for math genius! #maths
00:29
FLIP FLOP Hacks
Рет қаралды 18 МЛН
[Vowel]물고기는 물에서 살아야 해🐟🤣Fish have to live in the water #funny
00:53
Why? 😭 #shorts by Leisi Crazy
00:16
Leisi Crazy
Рет қаралды 46 МЛН
Osman Kalyoncu Sonu Üzücü Saddest Videos Dream Engine 118 #shorts
00:30
18 Commands That Will Change The Way You Use Linux Forever
29:50
Akamai Developer
Рет қаралды 1,2 МЛН
Why Linux is better for (most) developers!
14:59
The Linux Experiment
Рет қаралды 459 М.
10 Simple Tips to Help You SUCCEED At Learning Linux
19:13
Learn Linux TV
Рет қаралды 363 М.
Linux Crash Course - The lsof Command
23:49
Learn Linux TV
Рет қаралды 29 М.
BASH scripting will change your life
14:18
NetworkChuck
Рет қаралды 991 М.
Linux Crash Course - Understanding Logging
29:10
Learn Linux TV
Рет қаралды 43 М.
How To Install CSI Linux - Master CSI Linux for OSINT! InfoSec Pat
12:56
Bash vs ZSH vs Fish: What's the Difference?
13:32
Eric Murphy
Рет қаралды 150 М.
Beginner's Guide To The Linux Terminal
42:27
DistroTube
Рет қаралды 343 М.
iphone fold ? #spongebob #spongebobsquarepants
0:15
Si pamer 😏
Рет қаралды 129 М.
What percentage of charge is on your phone now? #entertainment
0:14
как спасти усилитель?
0:35
KS Customs
Рет қаралды 493 М.
🤔Почему Samsung ПОМОГАЕТ Apple?
0:48
Technodeus
Рет қаралды 458 М.
Куда пропал 3D Touch? #apple #iphone
0:51
Не шарю!
Рет қаралды 608 М.