Skip to content

Commit 81f18d1

Browse files
committed
bashrc
1 parent 1c7374c commit 81f18d1

File tree

3 files changed

+161
-0
lines changed

3 files changed

+161
-0
lines changed

blogs/aws_ml_specialist.html

Whitespace-only changes.

blogs/bash.html

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<title>Akash Singh</title>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
7+
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Inconsolata">
8+
<style>
9+
body, html {
10+
height: 100%;
11+
font-family: "Inconsolata", sans-serif;
12+
}
13+
.bgimg {
14+
background-position: center;
15+
background-size: cover;
16+
background-image: url("./img/ml.jpg");
17+
min-height: 75%;
18+
}
19+
.menu {
20+
display: none;
21+
}
22+
.container{
23+
width: 80%;
24+
margin: auto;
25+
}
26+
</style>
27+
<body>
28+
<!-- Links (sit on top) -->
29+
<div class="w3-top">
30+
<div class="w3-row w3-padding w3-black">
31+
<div class="w3-col s3">
32+
<a href="https://akashzcoder.github.io" class="w3-button w3-block w3-black">HOME</a>
33+
</div>
34+
<div class="w3-col s3">
35+
<a href="https://akashzcoder.github.io/#about" class="w3-button w3-block w3-black">ABOUT</a>
36+
</div>
37+
<div class="w3-col s3">
38+
<a href="https://akashzcoder.github.io/#resume" class="w3-button w3-block w3-black">RESUME</a>
39+
</div>
40+
<div class="w3-col s3">
41+
<a href="https://akashzcoder.github.io/#academicWriting" class="w3-button w3-block w3-black">BLOGS</a>
42+
</div>
43+
</div>
44+
</div>
45+
<div class="w3-grayscale w3-large">
46+
<!-- About Container -->
47+
<div class="w3-container container" id="about">
48+
<p class="w3-content" style="max-width:700px">
49+
<h5 class="w3-center w3-padding-64"><span class="w3-tag w3-wide">Master the Bash Shell</span></h5>
50+
</p>
51+
52+
<p class="w3-content" style="max-width:900px">
53+
<b>CORE BASH</b><br>
54+
Bash is a shell program. Shell program is typically an executable binary which takes in input command and
55+
translates those to system calls that can interact with Operating System API. Also, <it>bash</it> is not
56+
not the only kind of shell program. There are many variants to this:
57+
<ol class="w3-content" style="max-width:900px">
58+
<li>Thompson Shell - 1971,</li>
59+
<li>Bourne Shell (sh) - 1977,</li>
60+
<li>C shell (csh) - 1978, </li>
61+
<li>Bourne Again Shell (bash) - 1987, etc.</li>
62+
</ol>
63+
< class="w3-content" style="max-width:900px">
64+
Bash is the most widely seen, used and available shell. However, it is still not unheard of to end up on
65+
servers that do not have bash!<br><br>
66+
<b>Globbing: </b>
67+
Regular expressions are patterns used to search for matching strings. Globs look similar and perform a
68+
similar function, but are not the same. That’s the key point to understand about globs vs regular expressions.
69+
For example: * -> zero or more characters, ? -> matches for any single character, [abd] -> matches for any character from a, b or d,
70+
[a-d] -> matches from any character between a to d.
71+
<br><br>
72+
<b>Quoting: </b> Single quotes and double quotes have different meanings in bash.
73+
Quoting changes the way bash can read the line, making it decide whether to take these characters and
74+
transform them into something else, or just leave them be. In other words, any expression inside the double
75+
quotes gets interpreted whilst no evaluation happens when single quote is used. There is no special meaning
76+
to any character in single quote.<br>
77+
Note: Globs are neither evaluated in double quotes nor in single quotes.<br><br>
78+
<b>Dotfile: </b> dot files are hidden files, It is used you want to have a file that sits
79+
alongside other files but that is generally ignored. For example, you might write some code that
80+
reformats a set of text files in a folder, but you don’t want to reformat a dotfile that contains
81+
information about what’s in those text files. You cannot use the command <em>ls *</em>: this command
82+
won't list hidden files instead we will have to use <em>ls .*</em>.<br><br>
83+
<b>direct assignment VS export VS using .bash_profile</b> direct assignment of variables are accessible within
84+
a shell and as soon as a new shell is opened such variables will no longer be accessible. An alternate for
85+
accessing variables across multiple bash within the same shell is to use <em>export</em> command.
86+
For example, export LAST='Singh'. This command will be ensure the presence within the same terminal session.
87+
Still if access is needed across different terminals, use the <em>~/.bash_profile</em>(this file will
88+
change based on the version of shell being used). Write <em>export LAST=Singh</em> in .bahs_profile file.
89+
Since this file is loaded on every new terminal launch, therefore all the variables gets exported in every new terminal.
90+
Other interesting commands include: <b>env</b> which is used to display all the environment variables,
91+
<b>compgen -v</b> is used to print all the variables in the env. Although, the main use of compgen command is to
92+
display any autocomplete command in terminal including the variables, for example <em>-v</em> is used with this command to print all
93+
the variables.
94+
<br><br>
95+
<b>Functions: </b> Syntax of function is as shown below: <br>
96+
$function testfx {<br>
97+
> &nbsp;&nbsp;&nbsp;echo $1<br>
98+
> &nbsp;&nbsp;&nbsp;echo $2<br>
99+
>}<br>
100+
Scope of variables are same as how it would behave whilst you use these instructions over a shel without the
101+
method. However, on occasions where local variables are needed we can set those inside the function using the
102+
keyword local. When a key local is used before a variable, its scope is limited to the function and the variables
103+
will not impact the execution outside the method. <br><br>
104+
<b>Builtins: </b> Builtins are commands that come ‘built in’ to the bash shell program. Normally you
105+
can’t easily tell the difference between a builtin, a program or a function. The best way to distinguish
106+
is to type builtin and one of those next to it. For instance if there is a function that you wrote with
107+
the same name as a builtin, then the best way to call the builtin is by typing builtin followed by the
108+
bash command.
109+
<br><br>
110+
<b>Aliases: </b> Finally there are aliases. Aliases are strings that the shell takes and translates to whatever
111+
that string is aliased to. Aliases take precedence over builtins.<br><br>
112+
<b>Redirects: </b> Lets look at some examples, its simpler that way: <br>
113+
<em>echo "contents of file1" > file1</em><br>
114+
The <em>></em> character is the redirect operator. This takes the output from the preceding command that you’d normally see in the terminal and sends it to a file that you give it.
115+
Here it creates a file called file1 and puts the echoed string into it.<br><br>
116+
<b>Pipes: </b> Lets look an example:<br>
117+
<em>cat file1 | grep -c file</em>
118+
Normally you’d run a grep with the filename as the last argument, but instead here we pipe the contents of file1 into the grep command by using the ‘pipe’ operator: |.
119+
The resulting output of 1 indicates the number lines that matched the word file in the the file called file1.
120+
These are the numbered file descriptors, and the first three are assigned to the numbers 0,1 and 2.
121+
0 is standard input,
122+
1 is standard output, and
123+
2 is standard error
124+
125+
126+
127+
128+
</p>
129+
</p>
130+
131+
</div>
132+
</div>
133+
</div>
134+
<!-- Footer -->
135+
<footer class="w3-center w3-light-grey w3-padding-48 w3-large">
136+
<p>
137+
Copyright &#x000A9;&nbsp;2020 &#x000B7; Akash Singh
138+
</p>
139+
</footer>
140+
<script>
141+
// Tabbed Menu
142+
function openMenu(evt, menuName) {
143+
var i, x, tablinks;
144+
x = document.getElementsByClassName("menu");
145+
for (i = 0; i < x.length; i++) {
146+
x[i].style.display = "none";
147+
}
148+
tablinks = document.getElementsByClassName("tablink");
149+
for (i = 0; i < x.length; i++) {
150+
tablinks[i].className = tablinks[i].className.replace(" w3-dark-grey", "");
151+
}
152+
document.getElementById(menuName).style.display = "block";
153+
evt.currentTarget.firstElementChild.className += " w3-dark-grey";
154+
}
155+
document.getElementById("myLink").click();
156+
</script>
157+
</body>
158+
</html>

index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,9 @@ <h3>Academic Writings</h3>
537537
<div class="card">
538538
<div class="card-header"><a href="blogs/machine_learning.html">Machine Learning Based Architectures</a></div>
539539
</div>
540+
<div class="card">
541+
<div class="card-header"><a href="blogs/bash.html">Master the Bash Shell</a></div>
542+
</div>
540543
</div>
541544
<div class="container">
542545
<div class="card">

0 commit comments

Comments
 (0)