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