Hello Programmers, I’m Yash. Sole programmer at planetvearcity – a place where programmers come to learn, build, and grow.
Welcome to the tutorial series on shell scripting. In this video, we will cover comments and variables.
When writing Shell scripts, it is always a good practice to make your code clean and easily understandable. One of the ways to improve the readability of your code is by using comments. Adding comments to your scripts will make it easy for you to understand your code in the future. Let us go ahead and try using comments.
Comments are also useful when testing a script. Instead of deleting some lines, you can comment them out. If you are using a code editor like me then there is a shortcut to comment a given line or selected portion. In vs code its command plus forward slash.
Hello, I’m Yash. Sole programmer at planetvearcity – a place where programmers come to learn, build, and grow.
Welcome to the new tutorial series on shell scripting. In this video, we will be covering the introduction of shell scripting and write a hello world script.
Before we begin. I recommend you guys to watch my Linux command line tutorial. I have posted the link in the description. That tutorial is a prerequisite to this tutorial series. Moving along I will assume you understand basic Linux commands.
The shell script is a computer program designed to be run by the Unix/Linux.
When working on the command line, quite often you will need to create or edit files. Two of the most famous and powerful command-line editors are Vim and emacs. On the other hand, they are equally difficult to learn. But there is a simpler editor available to just get things done and that is nano.
All commands are prefixed with a control(^) character or metacharacter(M). caret symbol represents control and M represents Meta. Control will generally be your control key. Meta character depends on the keyboard setup. It can either be an Esc key, alt key, or a special meta key.
In this video, I will help you learn the basic usage of the nano editor, including how to create an open file, edit a file, save a file, search and replace text, cut and paste text, and more.
If you wish to get more help, while inside nano editor hit: ^G
In this video, we will learn how to use less command. less is a command-line utility that displays the content of a file or a command output, one page at a time. The less command is mostly used for opening large files.
The general syntax for using less command is:
less [options] filename
It is also possible to use less with other commands output.
ls /etc | less
When opening a file that is too large to fit in one page, you will see the colon at the bottom of the screen. What makes less more appealing is its ease of file navigation.
In this video, we will learn how to use touch command. The main purpose of this command is to change file access and modification time but it can be used to create a new file. In simple terms, it is used to change the timestamp of a given file.
touch can create a new file too. I find it much simpler to create a new file using touch. It is possible to create a file with any file extension. Moreover, you can create multiple files with just one command.
Remember you can always type man touch to learn more about the command.
We will also learn about some flags along with touch command:
-t = pass in custom timestamp -a = just change access timestamp -m = just change the modified timestamp -r = copy timestamp from another file