Working with Tmux Session

sudhir sharma
Updated on 17-Jul-2020 10:52:40

432 Views

Tmux is a terminal multiple for Unix OS. It provides multiple terminal sessions to its users. It is used when we are using cloud-based services (like Azure, AWS) for the creation of separate terminals for different remote users.While working with web services, one needs to create an EC2 instance on the webserver provided by the company to work on it by creating a session.Now, let’s see the steps of working on a UNIX (Ubuntu) webserver.Step 1 − Write/copy the IP address of your AWS console and download the key file from the console. You will get these from your vendor ... Read More

Print a Particular Line from a File in C using Bash Script

sudhir sharma
Updated on 17-Jul-2020 10:50:06

358 Views

In this program, we are given a file name text.txt. Our task is to print a particular line from the file.For this there are multiple methods in bash script, they are awk, sed, head.Syntax$> awk ‘{if(NR==LINE_NUMBER) print $0}’ filename $> sed -n LINE_NUMBERp filename $head -n LineNumber filename | tail - n + LINE_NUMBERCode to print a specific line in bash programming from file text.txt.Using awk$> awk ‘{if(NR==5) print $0}’ text.txtUsing sed$>sed -n 5p text.txtUsing head$head -n 5 filename | tail - n + 5

Display File Contents Like More Utility in Linux using C

sudhir sharma
Updated on 17-Jul-2020 10:48:40

260 Views

Here, we will write a C program that will display the contents of a file page by page as displayed in Linux using the more command.This program will show a specific number of lines on the screen first and then wait for the user to hit enter to move to the next page i.e. next set of n lines.For displaying the content of the file like this we will open the file and print its contents. And maintain a counter for new lines in the file. When this counter reaches n, we will read a key pressed by the user ... Read More

C Program That Won't Compile in C++

sudhir sharma
Updated on 17-Jul-2020 10:33:40

270 Views

Here, we will write some c programs that won’t compile in c++. Though c++ is considered as a successor of c that has all its features and has compatibility with c code there are some programs that won’t compiler or given a compilation error when compiled with c++ compiler.A list of some of the C programs that won’t compile in c++ are −Call to a function before declaration − In c++, function call before declaration gives compilation error. But this works fine in c.Example Live Demo#include int main(){    printHello();    return 0; } void printHello(){    printf("TutorialsPoint"); }OutputTutorialsPointUsing typecasted ... Read More

Best Way to Add an Event in JavaScript

AmitDiwan
Updated on 17-Jul-2020 09:12:58

139 Views

The best way to add an event to any element is to use the addEventListener() method.Following is the code to add an event in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result{       font-size: 20px;       font-weight: 500;       color: rebeccapurple;    } Adding event in JavaScript CLICK HERE Click on the above button to increment the font size of above text    let resEle = document.querySelector(".result");    document.querySelector(".Btn").addEventListener("click", () => {       resEle.style.fontSize = "34px";    }); OutputThe above code will produce the following output −On clicking the ‘CLICK HERE’ button −

Decrement a Date by 1 Day in JavaScript

AmitDiwan
Updated on 17-Jul-2020 09:11:04

260 Views

Following is the code to decrement a date by 1 day in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result,.sample {       font-size: 20px;       font-weight: 500;       color: rebeccapurple;    } JavaScript program to decrement a date by 1 day Decrement Click on the above button to decrement the date by one day    let resEle = document.querySelector(".result");    let sampleEle = document.querySelector(".sample");    let date = new Date();    sampleEle.innerHTML = date;    document.querySelector(".Btn").addEventListener("click", () => {       date.setDate(date.getDate() - 1);       resEle.innerHTML = "New Date = " + date;    }); OutputThe above code will produce the following output −On clicking the ‘Decrement’ button −

Find Keys of a Hash in JavaScript

AmitDiwan
Updated on 17-Jul-2020 09:09:10

420 Views

Following is the code for finding keys of a hash in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: 500;    } Find keys of a hash in JavaScript DISPLAY Click on the above button to display the hash keys    let resEle = document.querySelector(".result");    let obj = {       firstName: "Rohan",       lastName: "Sharma",       age: 22,    };    document.querySelector(".Btn").addEventListener("click", () => {       resEle.innerHTML += "object keys are " + Object.keys(obj);    }); OutputThe above code will produce the following output −On clicking the ‘DISPLAY’ button −

Validate Decimal Numbers in JavaScript

AmitDiwan
Updated on 17-Jul-2020 09:02:49

520 Views

Following is the code to validate decimal numbers in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: 500;    } Validate decimal numbers in JavaScript CHECK Click the above button to check if a valid decimal number is entered or not    let resEle = document.querySelector(".result");    document.querySelector(".Btn").addEventListener("click", () => {       var str = document.querySelector(".num").value;       var regex = /^[-+]?[0-9]+\.[0-9]+$/;   ... Read More

Remove Child Node in HTML using JavaScript

AmitDiwan
Updated on 17-Jul-2020 08:58:54

199 Views

Following is the code to remove a child node in HTML using JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: 500;    } Removing a child node in HTML using JavaScript Cow Lion Tiger Buffalo CLICK HERE Click the above button to remove the first list element from the above list    let resEle = document.querySelector(".result");    let animalList = document.querySelector(".animal");    document.querySelector(".Btn").addEventListener("click", () => {       animalList.removeChild(animalList.childNodes[0]);       animalList = animalList;    }); OutputThe above code will produce the following output −On clicking the ‘CLICK HERE’ button −

Load JavaScript File Dynamically

AmitDiwan
Updated on 17-Jul-2020 08:56:27

637 Views

Following is the code to load a JavaScript file dynamically −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: 500;    } Load a JavaScript file Dynamically CLICK HERE Click the above button to load external JavaScript    let resEle = document.querySelector(".result");    document.querySelector(".Btn").addEventListener("click", () => {       var jsRef = document.createElement("script");       jsRef.setAttribute("src", "sample.js");       document.getElementsByTagName("head")[0].appendChild(jsRef);    }); script.jsresEle.innerHTML='JavaScript has been loaded';OutputThe above code will produce the following output −On clicking the ‘CLICK HERE’ button −

Advertisements