0:00
hey everyone welcome back to our channel
0:02
the place where we simplify Linux
0:04
scripting and cloud technology step by
0:07
step In today's video I will show you
0:10
how to add single line and multi-line
0:12
commands in cell scripts It is an
0:14
essential skill to make your scripts
0:16
clear organized and easier to maintain
0:19
Let's get started Before we dive into
0:22
the how let's quickly understand why
0:24
comments matter It explain what the
0:26
script does It describe complex logic It
0:30
temporarily disable the lines during the
0:32
testing Help others to understand your
0:35
code easily Trust me clear commands can
0:38
save you hours of confusion later Now
0:41
let's see how to add a single line
0:43
command in a cell script For the
0:45
interest of time I have a demo script So
0:48
in order to add a single line command
0:51
it's simple Start the line with a hash
0:53
symbol Let's open the script using vi
0:59
editor Let's say under this package
1:02
management I would like to put a
1:06
command for this command For that go to
1:09
the insert modes Type h has symbol at
1:12
the beginning of line Now save the
1:17
file Now during the execution of this
1:19
script this line will not be executed
1:23
because we have put command using a hash
1:26
symbol All right What about multi-line
1:29
commands b doesn't have built-in
1:31
multi-line command syntax like other
1:33
programming languages But there are
1:36
couple of easy workarounds through which
1:37
we can have multiple line commands in
1:40
our shell script The first method is
1:42
using multiple hash symbols Let's assume
1:45
I want to comment out this complete uh
1:48
section package management For that I
1:50
have to comment out all of these lines I
1:54
can do it using multiple hash symbols Go
1:57
to the insert mode again and type hash
2:00
at the beginning of each
2:02
line Now save the file By using multiple
2:06
hash symbols we have completely comment
2:09
out the package management section here
2:12
What if this package management could
2:14
have uh 100 plus of lines then putting
2:18
hash in front of each line will take
2:21
time So in order to overcome that we
2:24
have another method We call it hair
2:27
document with colon Let's see how we can
2:29
implement that Let me remove the
2:33
comments Type here colon then double
2:36
less than symbol in quotes Type comments
2:41
comment at the end Close this section
2:44
with a comment keyword Now save this
2:53
This indicates that starts a hair
2:57
document and everything mentioned
2:59
between this comment section will be
3:02
ignored or we can say that it is
3:05
commented out So during the execution of
3:07
the script this package management
3:09
section will be ignored We can also
3:11
implement multi-line commands using pure
3:14
do without colon For this we have to
3:21
only The rest of syntax will remain the
3:24
same Let's save the file Everything
3:27
unclosed in the comment section will be
3:30
ignored or we can say it would be
3:31
commented out So when we execute the
3:34
script this package section will not be
3:37
executed If you want to remove this
3:39
comments you simply delete the beginning
3:45
document and delete this comment
3:49
keyword and save the file If you are
3:52
using Vim editor in order to edit the
3:55
script then you can use visual mode as
3:58
well in order to add single or
4:00
multi-line commands How we can do that
4:06
see Let's suppose I want to comment out
4:10
this backup important directory
4:13
section For that what I can do first I
4:16
need to enter into the usual mode For
4:19
that type control V Use keys to select
4:29
I We will enter into the insert mode
4:32
Type hash symbol And when you do
4:36
escape it will automatically add hash
4:39
symbol at the beginning of all the
4:42
selected lines Now you can save this
4:45
file In order to remove these commands
4:49
in visual mode again enter into the
4:52
visual mode by typing Ctrl +V Use down
4:55
arrow keys and select the
4:58
lines and press X to delete the hash
5:02
symbol Save and close the
5:05
file And that's it Now you know exactly
5:09
how to add single line or multi-line
5:11
commands in your cell scripts If you
5:13
found this video tutorial helpful give
5:16
it a thumbs up Consider subscribing to
5:18
our channel for more Linux tutorials
5:20
scripting tips and cloud guides every
5:22
week Do not forget to hit the bell icon
5:24
to stay updated with all future uploads
5:28
Got questions or want to see more
5:29
scripting tutorials drop a comment below
5:32
I would love to hear from you Thanks for
5:35
watching See you in the next one back