In order to create a crontab job to run every 30 minutes we first need to explore and understand what a crontab job is.A crontab is nothing but a list of commands that we can run during a cron job. A cron job is a utility that schedules automatic execution of commands at specific times.We can start a cron job with the help of bash script by following the commands shown below −crontab -eThis will open a file which you can edit, insert the cron job shell script in the above file and then close that file.Just insert the code ... Read More
Setting a variable to a single line in bash and then printing it to console is a fairly easy process, but if we want to write multiple line strings using Bash then we have to consider different approaches.In total there are three approaches that we can make use of, all of these are mentioned below with examples.Multiline with We can make use of the symbol to make sure that whatever string we write has a newline in between them. With this approach we can write as many lines as possible, we just need to write the same number of ... Read More
In Python, we have the subprocess module that allows us to work with additional processes and makes things easier for us as a developer. While there are other modules available to us that also provide similar functionalities as the subprocess module like the os.spawn(), os.system(), os.popen() and much more, but the reason the subprocess is recommended over all these modules is because of its offering of a high level interface than all the other similar modules mentioned above.In order to be able to use pipes along with the subprocess module we need to understand what the subprocess module does first.ExampleLet’s ... Read More
Let’s consider a case where we have two directories, say, d1 and d2 and both these directories contain some files, which may be the same or different. Now we want to make use of the sed command to replace a particular text that might be present in some of the files in either the d1 directory or the d2 directory.In order to do that, we must be familiar with the sed commands, as the sed commands can be used to solve the above problem.Let’s first explore the sed command, which is short for stream editor. This command is used to ... Read More
In order to be able to grep a string that has a dot inside it, we must first understand what a grep command is and how to use it on Linux.The grep command in Linux is used to filter searches in a file for a particular pattern of characters. It is one of the most used Linux utility commands to display the lines that contain the pattern that we are trying to search.Normally, the pattern that we are trying to search in the file is referred to as the regular expression.Syntaxgrep [options] pattern [files]While there are plenty of different options available ... Read More
Linux find statement is one of the most widely used statements that allows us to walk a file hierarchy. It is used to mostly find a specific file or directories and we can also append different other Linux statements or flags along with it to enhance or do a complex operation.Let’s explore an example of a find statement to understand it better.In the Linux code shown below, I am trying to search for a file inside my Downloads folder, and for that I am making use of the find statementfind sample.shOutputsample.shNotice that if the find command is able to locate ... Read More
Unzip is the Linux command utility that we will use to unzip all zipped files present in a Linux directory.By default, the unzip utility is not present on most of the Linux distributions and we can install the same with the help of the commands mentioned below.For Ubuntu and Debiansudo apt install unzipFor CentOS and Fedorasudo yum install unzipSyntaxunzip file.zipIn the above syntax we just need to replace the file.zip with the file that we want to unzip.Consider a case where I have a directory named direct1 that looks something like this −immukul@192 direct1 % ls -ltr total 5216 -rwxrwxrwx ... Read More
In order to test a crontab job we first need to explore and understand what a crontab job is.A crontab job is nothing but a list of commands that we can run during a cron job. A cron job is a utility that schedules automatic execution of commands at specific times.We can start a cron job with the help of bash script by following the commands shown below −crontab -eThis will open a file which you can edit, insert the cron job shell script in the above file and then close that file.Just insert the code shown below in the ... Read More
The grep command in Linux is used to filter searches in a file for a particular pattern of characters. It is one of the most used Linux utility commands to display the lines that contain the pattern that we are trying to search.Normally, the pattern that we are trying to search in the file is referred to as the regular expression.Syntaxgrep [options] pattern [files]While there are plenty of different options available to us, some of the most used are −-c : It lists only a count of the lines that match a pattern -h : displays the matched lines only. ... Read More
An Environment variable is a dynamic-named value. Generally, these are variables are exported in a single terminal using a command shown belowexport $SOMEVARIABLE=valueor they are stored inside the bash files, so that they remain available in all the terminals once the file is sourced. If we want to change an environment variable we can simply change the above command’s value field and then source the file, but if we want to do that with the help of the sed command then we need to know a little bit about the sed command.Let’s explore the sed command, which is short for ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP