-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
samirm00
committed
Mar 5, 2024
1 parent
dabf0ab
commit f0af189
Showing
3 changed files
with
111 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
# Author: Samir M. | ||
# Date: 2024-03-05 | ||
# Modified: 2024-03-05 | ||
# Description: Quoting | ||
# Usage: .\02.sh | ||
|
||
# Quoting: is about removing the special meaning of characters. | ||
# There are three types of quotes in bash: single quotes, double quotes, and back slashes. | ||
|
||
# Single quotes: | ||
# Single quotes are used to prevent the interpretation of all of the special characters. | ||
|
||
# example | ||
filepath1='\home\sam\My Documents' | ||
echo $filepath1 # \home\sam\My Documents | ||
|
||
# Double quotes: | ||
# Double quotes are used to prevent the interpretation of most of the special characters, except $ , back ticks ` and \. | ||
|
||
# example | ||
filepath2="\home\\${USER}\My Documents" | ||
echo $filepath2 # \home\sam\My Documents | ||
|
||
# Back slashes: | ||
# Back slashes are used to prevent the interpretation of the next character. | ||
|
||
# example | ||
echo Hello John \& Jane # Hello John & Jane | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
# Author: Samir M. | ||
# Date: 2024-03-05 | ||
# Modified: 2024-03-05 | ||
# Description: Tokenisation | ||
# Usage: .\02.sh | ||
|
||
# Tokenisation: | ||
# The process of breaking a command line into its a smaller parts called tokens using metacharacters. | ||
|
||
# What are metacharacters? | ||
# Metacharacters are characters that have a special meaning to the shell. | ||
# The metacharacters are: space, tab, newline, ;, (, ), <, >, |, and &. | ||
|
||
# The token can be either a word or an operator. | ||
# A word doesn't contain any unquoted metacharacters. | ||
# An operator does contain at least one unquoted metacharacters. | ||
|
||
# Example: | ||
|
||
name="Sam" | ||
echo $name > file.txt | ||
# we have 5 metacharacters here: space, > and newline. | ||
# we have 4 tokens: echo, $name and file.txt all are words, because they don't contain any unquoted metacharacters. | ||
# > is an operator, because it contains one unquoted metacharacter. | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
exit 0 |