212 Bash Scripting Examples

preview_player
Показать описание
Liked this course and looking for more?
Please visit our refreshed and improved 4-hr Bash Boot Camp Course here:

***(TIMELINE - 1)***

# Simple Hello World Script 00:00:35
# Echo Command Without Newlines 00:04:20
# String Concatenation With Echo 00:06:13
# String Continuation Character 00:07:40
# Echo with Tab Characters 00:09:12
# Echo with Newline Characters 00:11:12
# Echo with -x to Display All Commands 00:12:30
# Printing Strings That Contain Single Quotes 00:14:46
# Printing Strings That Contain Double Quotes 00:16:00
# Write to a File from Inside A Script 00:18:07
# Overwrite to a File from Inside A Script 00:20:04
# Append to File Inside Script 00:21:41
# Single Line Comments 00:23:40
# Comments From Middle of Line 00:25:45
# Multi Line Comments Using Heredocs 00:27:56
# Simple Variable Usage 00:30:16
# Multi Word Variables Combinations with Quotes 00:32:27
# HOME variable 00:35:28
# USER variable 00:38:16
# HOSTNAME variable 00:39:24
# Echo $HOME with Escape to Avoid Expansion 00:40:16
# Writing to file in HOME Directory Using HOME Environment Variable 00:41:34
# Simple Touch Command 00:44:47
# Create a Symbol Link, Write To Linked File, Cat file 00:46:57
# Chmod Command, Make Executable 00:50:40
# Chmod Command, Make Not-Writable, Try to Write to it 00:53:29
# Chown File To Different User, Run ls before, after 00:56:44
# Underscore Variable, Touch File, Use Underscore Variable to Append to It 00:59:59
# Let Command Arithmetic 01:03:42
# 4 Basic Operators, Add, Subtract, Multiply, Divide 01:05:13
# Increment a variable 3 times with Increment Operator 01:07:56
# Decrement a variable 3 times with Decrement Operator 01:10:34
# Echo Number Modulus Second Number 01:12:36
# Echo Number to Exponent of Second Number 01:14:50
# Expr Command for Math 01:16:17
# Double Parenthesis for Math 01:19:14
# Double Parenthesis with Dollar Operator Assign to Variable 01:21:40
# Multiplication has Precedence Over Addition Regardless of Order 01:23:43
# Combine Two Strings In One Line With Variables 01:25:49
# Combine Three Strings In One Line With Variables 01:29:09
# Plus Equal Operator Combine Strings 01:31:24
# Create Multi-Line String Variable with HEREDOC 01:34:38
# Cat Multi-Line HEREDOC Text 01:37:04
# If Conditional Statement 01:39:43
# Logical And in Conditional Statement 01:43:00
# Logical Or in Conditional Statement 01:46:53
# If Elif Else Conditional Statement 01:51:29
# Nesting If Conditions 01:58:28
# Equal vs Double Equal Operator 02:01:36
# Test Not Equal Strings 02:05:03
# Test Two Strings Before or After alphabetically 2:06:33
# Test String is Null 02:08:07
# Test String is Not-Null 02:09:30
# Test Numerical Comparisons Greater then, Less then 02:10:39
# Test Numerical Compare Greater Then Or Equal, Less Than Or Equal 02:12:58
# Test Compare Numbers Are Equal 02:15:02
# Test Compare Numbers Are Not-equal 02:19:16
# Test File Exists 02:19:15
# Test File Is Not Zero Size 02:21:10
# Test File Is A Directory 02:22:43
# File Is A Symbolic Link 02:24:22
# Test File Has Read Permission 02:26:18
# Test File Has Write Permission 02:27:35
# Test File Has Execute Permission 2:28:57

#bash #bashscripting
Рекомендации по теме
Комментарии
Автор

Liked this course and looking for more?
Please visit our refreshed and improved 4-hr Bash Boot Camp Course here:

linuxhint
Автор

*** TIMELINE-2 ***
# Case Conditional Statement With Numbers 2:31:24
# Case Conditional Statement With Strings 02:34:02
# Case Conditional Statement With Wildcards 02:36:11
# Execute a Command With Backticks 02:38:13
# Execute a Command in a Dollar Parenthesis Variable 02:40:06
# Execute a Command and Capture STDOUT 2:42:00
# Execute a Command And Capture STDERR 2:43:40
# Execute a Command And Capture Return Code 02:44:49
# Bash Exec Command Hello World 02:46:20
# Eval Command 02:47:55
# For Loop List of Values 02:49:06
# For Loop on Range of Numbers 02:49:57
# For Loop Output of Command 02:50:26
# For Loop Files in Directory 02:51:26
# For Loop with Conditional Break 02:52:12
# For Loop with Conditional Continue 02:53:05
# While Loop With Integer Counter 02:53:41
# Until Loop Based on File Size 02:54:34
# Create an Array Variable Access by Index 02:55:21
# Create an Associative Array Variable Access by Index 02:55:52
# Accessing Array Members with Loop 02:56:36
# Time a Command 02:57:16
# Print Date 02:57:43
# Print Date With Format 02:58:19
# Print Seconds Elapsed for Block of Code 02:58:57
# Read Text From File, Print to Screen 02:59:27
# Read Text From File, If Condition Print to Screen 03:00:00
# Basic Read Command 03:00:44
# Read Command Into Array 03:01:16
# Read Command with Delimiter 03:02:08
# Read Command with Timeout 03:02:38
# Menu Option with Select Command 03:03:07
# Menu Option With Select Command From Array Variable 03:04:03
# Split String By Space 03:05:05
# Split String By Custom Delimiter 03:05:32
# Split String into Array Variable 03:06:04
# Split String by Multi-Byte Delimiter 03:06:35
# Parse Command Line Options with Position 03:07:33
# Parse Command Line Options With Shift Command 03:08:29
# Parse Command Line Using GetOpt 03:08:43
# Read Password from Stdin, Without Printing it 03:09:26
# Pipe Command Example 03:09:56
# Cat Pipe Word Count Example 03:10:36
# echo to bc Command for Math Expression Simple 3:11:46
# echo to bc Command for Math Expression More Complex 03:12:14
# Function Prints Common Text, Call Multiple Times 03:12:40
# Function Returns a String 03:13:10
# Function Takes Params, Returns Sum 03:13:56
# Tput Command to Print String 03:14:28
# Tput Command to Print Number 03:14:50
# Tput to Clear Terminal 03:15:35
# Tput to Print Attributes of Terminal Simple 03:15:52
# Tput to Print Attributes of Terminal More Complex 03:16:13
# Assign String Variable with Declare 03:16:36
# Check If Variable Created with Declare 03:16:55
# n Option for Declare to Nameref Alias 03:17:37
# Forcing Variable to Integer with Declare 03:18:14
# Forcing Case with Declare 03:18:45
# Readonly Variables with Declare 03:19:08
# Indexed Arrays with Declare 03:19:44
# Associative Arrays with Declare 03:20:12
# Define a Function if Not Already Defined Using Declare
# Automatically Answer Question with yes Command 03:20:36
# Use And Operator to Run Second Command Only if First Succeeds 03:21:03
# Use Or Operator to Run Second Command Only if First Fails 03:21:58
# xargs to operate on all files in directory 03:22:40
# Wait For Another Command to Complete 03:23:10
# Combine Kill and Wait Commands 03:23:57
# Star Wildcard on File Selection 03:24:27
# Question Mark Wildcard on File Selection 03:25:17
# Square Bracket on File Selection 03:25:45
# Parenthesis and Pipe for File Selection Options 03:26:12
# Brace Expansion Comma Seperated List 03:27:01
# Brace Expansion Range 03:27:26
# Brace Expansion with Preamble 03:27:51
# Operating on List of Files with Brace Expansion 03:28:11
# Reference Home Directory with Tilde 03:28:40
# Parameter Expansion for Printing Constant or Variable if Unset 03:28:59
# Substring Expansion for Printing Part of String 03:29:25
# Parameter Expansion for Assigning Constant to Variable if Unset 03:29:55
# Check If File Executable, Set If Not 03:30:22
# Check If File Is Owned By User, Set If Not 03:31:18
# wc To Count Lines In A File 03:31:59
# wc to Count Characters in a File 03:32:38
# Head Command With Default Args 03:33:05
# Head Command to Print First 100 Lines 03:33:32
# Tail Command With Default Args 03:33:57
# Tail Command to Print Last 100 Lines 03:34:15
# Find Command to Locate Matching Pattern Files 03:34:33
# Find Command to Locate Files Based on Date 03:35:44
# cut Command to Parse Delimited Columns of Data 03:36:21
# grep Command to Search for Pattern 03:37:14
# grep Command to Search for Lack of Pattern 03:37:38
# grep Command to Search for Case Insensitve Pattern 03:38:03
# grep Command with Wild Cards 03:38:34
# grep Command to Search All Files in Directory Recursive 03:39:01
# grep Command to Search for File in a Directory Recursively 03:39:34
# awk Split On Whitespace 03:40:27
# awk Print Last Field in Each Line 03:41:07
# awk Print Only Match of Regex 03:42:00
# awk With If Else Condition 03:42:23
# awk With Ternary Operator 03:43:05
# sed To Replace Matching Text 03:43:38
# sed To Replace Second Instance of Matching Text on Line 03:44:06
# sed to Delete Specific Lines 03:44:39
# sed to Add a Line Before Matched Line 03:45:04
# sed to Add a Line After Matched Line 03:45:41
# Sort Data in File with sort Command 03:46:02
# Sort Data Ignore Case 03:46:29
# Sort Data numerically 03:46:58
# Print Unique Data with uniq Command 03:47:31
# Count Unique Lines in File with Sort, Uniq, and wc 03:48:22
# Convert Data to Uppercase with tr 03:50:15
# Convert Data to Lowercase with tr 03:52:06
# Create a tar File 03:53:44
# Create a Zipped Tar File 03:55:58
# Unzip a Compressed Tar File 03:57:14
# Parse JSON File with jq 03:59:01
# Print Specific Field in JSON with jq 04:01:49
# Print Cpu Info With Pseudo Filesystem 04:04:34
# Print Mem Info With Psuedo Filesystem 04:07:01
# Print Mounts With Psuedo Filesystem 04:08:10
# Print Network Stats With Psuedo Filesystem 04:09:45
# Print Disk Usage with du 04:12:10
# Print Disk Usage Human Readable with du 04:15:04
# Create File of Specified Size with dd 04:17:07
# Time Disk Writing with dd and time 04:19:22
# Send a Mail with mail Program 04:20:35
# Send a Mail with mail Program Change Subject 04:25:39
# Send a Mail with mail Program to Multiple Recipients 04:27:08
# Send a Mail with mail Program to CC and BCC list 04:29:00
# Print Mounts Usage with df 04:30:40
# Send a Mail with mail Program with Encoded Attachment 04:32:36
# Download Webpage with Curl 04:36:22
# Post to HTTP with Curl 04:39:31
# Put Command in Background 04:41:02
# Resume Command From Background 04:42:05
# Execute Last Command Again with Bang Bang 04:42:58
# tee Command to Print to File and Screen 04:43:57

linuxhint
Автор

Thank you so much for this tutorial. I have been scared of bash scripting up until i found this tutorial. Your delivery is topnotch. Thank you!

austinlawan
Автор

This is one of the best tech youtube videos I have ever seen. Sincerely thank you!

wesg
Автор

Very much appreciated mann...thanks a lottt...was searching all over internet for proper exercises like these...buddy pls do lot more tutorials in bash like these

voyagervishu
Автор

My OS lab classes are starting this week, Lucky to find this GOLD ! Thanks a ton sir 😄

vinayakf
Автор

great tutorial! Congrats! I use the shell for my classes and your course is a great resource not only for learning but for teaching as well. PS: By the way, you course has been an inspiration to me and I also created 3 short videos on using the shell for text processing on my channel. You are more than welcome to take a look at them. Thanks again for your effort and the nice teaching style!

alextantos
Автор

Thank you so much for this upload. I'm learning and practising so much!!

marklamarr
Автор

I was searching for shell scripting questions for practice...only you have discussed the basics of shell scripting and that too in detail

rishavsinha
Автор

🔥🔥🔥Awesome🔥🔥🔥 Please upload more videos related to bash scripting 🔥🔥🔥

MillionaireBull
Автор

Great video! 02:04:36 --> ‘=’ operator is used to compare the equality of two string values, not type comparison. So when compare two strings, there is no difference between using '=' and '=='

calgarygaoshan
Автор

FOUND ANSWER! it does in fact WORK! im using "alias" to run it! NOT! [./] like you need to! thats my problem here. this is very educational! need to see how to modify my alias!

charlesklein
Автор

Outstanding tutorial, thank you so much :)

maryamii
Автор

Haven't seen it but liked it already!

patriotlightning
Автор

any document or article link where I can read it offline?

hemantjain
Автор

at approximately "9:09" it works! however thier is an ERROR that can occur! after backslash if you use a comment it will print the comment despite the FACT that it was highlighted in "blue" which implies it worked but it dont! and it will jam on next line! you cannot comment after backslash in script. obviously the backslash SEEs the comment because its a backslash! despite the fact that implies it wont by the script!

charlesklein
Автор

2:38:50, not a backtick (`) but a back slash (\)

josephmusembi
Автор

3:13:48 does not work for me :first.sh: line 4: retstr: command not found

goodg
Автор

Item #71 redirecting STDERR 2:44:00 does not work the way shown. Changing dest file name to stderr.out is still only catching stdout. (Note error message still comes to screen)
Also: output with "hello" does not match script code shown in video moments earlier.
Unix considers stderr to be file descriptor #2, and stdout is #1, stdin is #0
typing: command >2 errfile.txt > norm.txt sends any error message to errfile.txt, and
at the same time sends normal stdout to norm.txt
You can also use VAR=$(command >2 errs) with stdout in VAR, but send errors to file.

jsteins
Автор

How can I retrieve data from Sq;l and then write it to file without erasing the file content that was already there?

gomo