Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Open Source Articles
Page 96 of 123
How to add a Column of Numbers in Bash?
Overview This article examines how to total up numeric columns of data in a bash shell, looking at the bash tools available for the task and comparing their speed. Using The awk Tool We’ll start by calculating the sum of the values in a particular column using the awk (awk) program. $ awk '{Total=Total+$1} END{print "Total is: " Total}' numbers.csv Total is: 49471228 Let’s now take a look at the timing using the “time” command − $ time awk '{Total=Total+$1} END{print "Total is: " Total}' numbers.csv Total is: 49471228 real 0m0.228s user 0m0.141s sys 0m0.047s When The ...
Read MoreExtracting a substring using Linux bash
Overview Extracting a substring from a string is a basic and common operation of text processing in Linux. We're looking at different ways to extract substrings from strings using the Linux command line here. Extracting an Index-Based Substring Let’s first take a quick glance at how to extract index-based substring using four different methods. Using the cut command Using the awk command Using Bash’s substring expansion Using the expr command Next, we’ll see them in action. Using The cut Command We can extract characters starting at position N through position M from the input string using "cut" command. ...
Read MoreChange the Install directory with make install
Overview Generally, packages are installed in the default directory. Depending on the system's Linux version, it might be necessary to use a different directory such as /usr or /user/local. We might also want to install a particular software application for a single user rather than for the entire system. We'll take a look at how to change where packages get installed by running make uninstall. Using ./configure Parameters When using autoconf/automake to build software packages, a configure script with several standard parameters and (sometimes) additional custom parameters is provided. Some packages don't use autoconf but they usually offer a compatible ...
Read MoreMove all files except one on Linux
Introduction If you're working with Linux, there might be times when you'll want to copy several files at once and then remove some of them later. We're going to take a closer at several different methods for achieving such results. Renaming The Unwanted File You can rename the unwanted file so that it becomes a “.” (dot) file means hidden files, which means that mv won't be able to see it. After renaming the unwanted file using the asterisks, we’ll then use the regular expression to remove the rest of the files. /source_dir$ mv file5 .file5 /source_dir$ mv * ~/target_dir/ ...
Read MoreLoad Environment Variables in a Cron Job
Overview When crontab runs a command, it doesn't read any environment variables from files like ~/.bashrc, ~/.bash_profile, etc. Because cron runs tasks from a non-interactive, non-login shell, it doesn't need an interactive user Some applications require environmental variables to function correctly. We’ll discuss different methods for loading environmental variables from a crontab. Setting the BASH_ENV Variable We can set environment variables for our shell scripts by using the BASH_ENV variable. We set it up so that when we run our jobs, they're executed by a shell script. We can set up our shell so that when we open a new ...
Read MoreHow to use tmux on Linux?
Overview Tmux is a terminal multiplexing utility for Unix systems. It provides an interface between several programs running simultaneously on one computer. Tmux allows us to detach from any terminal sessions without killing them. We can then reattached to any of the terminal sessions later on. We’ll learn the tmux terminal emulator in Linux. Specifically, we’ll examine some of its features and commands. Installation You can install tmui on Debian-based Linux systems using the apt-get package manager. $ sudo apt-get update -qq $ sudo apt-get install -y tmux We can also use the yum command line tool to download ...
Read MoreHow to run amd64 Docker images on the arm64 host platform?
Before knowing how to run amd64 docker images on the arm64 host platform, we must know what this means. There is a term called multi-architecture or multi-platform docker container images. These images contain the ability to run on various base or host architectures provided at the time of containerization of the images. Need of Multiplatform images Suppose you are a DevOps engineer and you have to prepare a web-server for an IT company. You have an amd64 host platform but when you handed over the image to the company you came to know that the company only works on the ...
Read MoreHow to run Gunicorn on Docker?
In this article, we are going to learn about how to run Gunicorn on Docker. Before creating the docker container with the gunicorn functionalities, we must know some of the basics of web servers and gunicorn. Introduction to Gunicorn Let us suppose we have a web server that shows the output of a python code to the users. This web server will execute the python script each time a request came to it, this will cause it to restart, overload, and delay (heavy delay for huge scripts) in response. So the real problem here we have is a static server ...
Read MoreHow to Hot-Reload in ReactJS Docker?
Hot-Reloading is adding dynamic functionality to the react application on the web browser. This means if we change something in the code of the application it immediately reflects this change on the web application front. But before “reloading” anything we must know “loading”, that is to make some ReactJs project on the Node Docker container. Creation and Containerization of React App Step 1: React app Use the prebuild commands to create a basic react application. Example $npx create-react-app reactapp Output npx: installed 67 in 19.076s Creating a new React app in /home/hemant/project/reactapp. Installing packages. This might take ...
Read MoreExclude directories while using grep command?
Overview We often run a grep command to look for specific strings of text within files. The grep command provides some additional functionality that makes the search even better. A feature that allows you to exclude certain directories from recurrence. This is useful when searching through large amounts of data. Grep can be used with the −r option which will allow you to specify multiple patterns and then use the −v option to show only those files that match your pattern. We’ll discuss the different ways to achieve this. Exclude Single Directory The simplest way to do this would be ...
Read More