This post provides some pic notes for Shell Scripting Tutorials (a list of 62 short videos) .
- Shell Scripting Tutorial-2: Shell, Kernel, Terminal & More
No capital letters in bash shell command (All should be in lowercase)!
clear
who
pwd



- Shell Scripting Tutorial-3: View System Date, Calender
cal
date




- Shell Scripting Tutorial-4: Create Files & Directories
touch — create empty (plain text) files
mkdir — create directory (directory is the same thing as folder, in terminal it is called directory, on GUI interface it is called folder)
cd — change directory




- Shell Scripting Tutorial-5: Text Files: Create, Merge & Play
cat
cat > test — this will create a file called test and write text into the file. (Ctrl+ D to exit editing the file.)
cat < test (shortcut cat test) — this will open an existing file called test and print its content in the terminal.
cat random test > sample — this will merge two existing files called random and test, and write the content to a new file called sample


- Shell Scripting Tutorial-6: Rename & Delete Files & Directories
mv — rename (when the source and destination is in the same directory) or move files
rm
rm -r (r means recursive)
rmdir — rmdir (only for empty directory)

- Shell Scripting Tutorial-7: Create Copies, Links to Files & Directories
cp — copy files and /or directories
ln file1 file 2 — (file 1 is a physical copy of file 2, when file 1 changes, file 2 will be updated automatically and in real time)
ln -s file1 file1_soft — (file1_soft is a soft link of file1, when file1 was removed, file1_soft will not work, because the physical copy it refers to has been gone.)






- Shell Scripting Tutorial-8: File Permissions
- Shell Scripting Tutorial-9: See What’s In Using ‘ls’
- Shell Scripting Tutorial-10: Change File Permissions Using ‘chmod’
- Shell Scripting Tutorial-11: Count Lines, Words & Characters Using ‘wc’ (Also see Shell Scripting Tutorial-49: Count the number of words & sentences in a text file without using ‘wc’)
file * command


the out put of wc command:
number of line, word, and charactor in the input file.

wc -l number of lines
wc -w number of words
wc -c number of characters

- Shell Scripting Tutorial-12: Sort
- Shell Scripting Tutorial-13: Cut Through Your Files
- Shell Scripting Tutorial-14: Convert & Copy Files With ‘dd’
- Shell Scripting Tutorial-15: Get Help, View Fancy Text & Reduce File Size
- Shell Scripting Tutorial-16: Hello World!
- Shell Scripting Tutorial-17: Use Commands In Your Scripts
- Shell Scripting Tutorial-18: Shell Variables, Grab User Input Using ‘read’
- Shell Scripting Tutorial-19: Positional Parameters
- Shell Scripting Tutorial-20: More On Positional Parameters
- Shell Scripting Tutorial-21: Reverse Quotes Or Accent Graves
- Shell Scripting Tutorial-22: Count The Number of Command Line Arguments Using $#
- Shell Scripting Tutorial-23: Math On Integers Using ‘expr’
- Shell Scripting Tutorial-24: Operator Precedence
- Shell Scripting Tutorial-25: Math On Real Numbers
- Shell Scripting Tutorial-26: Escape Sequences
- Shell Scripting Tutorial-27: Do Cool Things With ‘tput’
- Shell Scripting Tutorial-28: ‘if-then’ Statement in Action
- Shell Scripting Tutorials-29: The ‘if-then-else’ Statement
- Shell Scripting Tutorial-30: Run Checks on Numbers
- Shell Scripting Tutorial-31: Run Checks On Files
-f file
-d direcotry
-s file size (greater than zero or not)
-c (character file, e.g., .dbf file)
-b (block file like video and image)
-r (read permission)
-w (write permission)
-x (executable or not)




- Shell Scripting Tutorial-32: Append Text to a File Through Shell Script

cat >> $fname — will not overwrite the existing content in the file and will append … cat > $fname will overwrite


- Shell Scripting Tutorial-33: Run Checks On Strings

-n (the length of the string is not zero)
-z (the length of the string is zero)
the output of $? is 0 means the operation is true, if false, the output is 1.

- Shell Scripting Tutorial-34: The ‘AND’ Logical Operator
-a AND logic operator


- Shell Scripting Tutorial-35: Count The Number of Characters in User’s Input in Your Script

because there is a new line symbol, so need to be -eq 2 for a character.



- Shell Scripting Tutorial-36: The ‘OR’ Logical Operator
-0 or logic operator
| pipe symbol
the output of echo $var as the input of wc -c, use reverse quote symbol to group it as a whole for -eq operator



- Shell Scripting Tutorial-37: The ‘case’ Statement


- Shell Scripting Tutorial-38: Another Date With ‘case’ Statement
| — the pipe symbol tells the case not to end the case statement after checking [aeiou]*, need to check [AEIOU]* as well for the first case statement.


- Shell Scripting Tutorial-39: The ‘while’ Loop


- Shell Scripting Tutorial-40: The ‘until’ Loop




- Shell Scripting Tutorial-41: The ‘for’ Loop




- Shell Scripting Tutorial-42: Rant & Little Work


Normally 0 is for success, 1 is for failure of the result of $?
2 means invalid.



- Shell Scripting Tutorial-43: Search Patterns Using ‘grep’












- Shell Scripting Tutorial-44: The ‘passwd’ File Explained



- Shell Scripting Tutorial-45: The Internal Field Separator (IFS)




the default IFS is white space.




- Shell Scripting Tutorial-46: ‘passwd’ File Revisited


- Shell Scripting Tutorial-47: Reading From a File
exec and tty command
exec — exec is a builtin command of the Bash shell. It allows you to execute a command that completely replaces the current process. The current shellprocess is destroyed, and entirely replaced by the command you specify. (more check here.)
tty — Print the file name of the terminal connected to standard input. ( check more at here.)
read — read is a builtin command of the Bash shell, which reads a line of text from standard input and splits it into words. These words can then be used as the input for other commands. (for more info check here.)



- Shell Scripting Tutorial-48: Sleep while you are at work
sleep command — used for delay (the unit of its parameter is in seconds)




- Shell Scripting Tutorial-49: Count the number of words & sentences in a text file without using ‘wc’
(see also Shell Scripting Tutorial-11: Count Lines, Words & Characters Using ‘wc’)


- Shell Scripting Tutorial-50: Fetch & Redirect Man Pages of commands using ‘for loop’
In this tutorial you’ll learn to iterate over contents of a text file using for loop.
- Shell Scripting Tutorial-51: Nested Loops
In this tutorial you’ll learn to use nested loops to print all possible combinations of digits 1, 2 and 3.
- Shell Scripting Tutorial-52: The ‘break’ Statement
In this tutorial you’ll learn to use the break statement to transfer control from within the loop to the first statement after the loop.
- Shell Scripting Tutorial-53: The ‘continue’ Statement
In this tutorial you’ll learn to use the ‘continue’ statement to skip iterations in loops.
- Shell Scripting Tutorial-54: More on Metacharacters
In this tutorial you’ll learn to execute multiple commands on a single line in the terminal without using a shell script.





- Shell Scripting Tutorial-55: Adding & Removing Users
In this tutorial you’ll learn to add or remove users on the system, also we’ll check out the ‘login’ command to login through a user account in a terminal window.
- Shell Scripting Tutorial-56: Know when users log in Part One
In this tutorial we’ll build a script that checks for a user every minute and then notifies us when it logs in and also displays the time the user was late in logging in.
- Shell Scripting Tutorials-57: Know when users log in Part Two
In this tutorial we’ll improve the script we built in the previous lesson.
- Shell Scripting Tutorial-58: Know when users log in Final Part
In this tutorial we’ll finish our work on the script we first met in the 56th tutorial. We’ll check every one second for the user and will also report time with greater precision.
- Shell Scripting Tutorial-59: Communicate with other users using ‘write’
In this tutorial you’ll learn to send messages to other users on your system using the ‘write’ command.
You’ll also learn to use ‘finger’ command to see which users who have disabled message reception and which have not.
one terminal (terminal 1):

Another terminal (terminal 2):

in terminal 1:

in Terminal 2:

In Terminal 1:

In terminal 2:
In terminal 1:

In Terminal 2:
EOF — End Of File

Finger command:
In terminal 1:

In Terminal 2:

In Terminal 1:
Note the * before pts/1 (that indicates newuser2 does not allow send msg to it)

- Shell Scripting Tutorial-60: Create Your Own Commands Using Functions
In this tutorial you’ll learn to create your own commands using functions.


unset command to remove customized functions in terminal.

- Shell Scripting Tutorial-61: Executing Multiple Scripts
In this tutorial we’ll learn to execute a script from another script; not a particularly hard thing to do but I recorded a tutorial on it anyway.




- Shell Scripting Tutorial-62: Conclusion
Thank you so much for watching the tutorials in this course. I hope you guys had as much fun watching the tutorials as I had recording them for you.


The END:) happy shell scripting!