Exclude Grep from PS Results on Linux

Satish Kumar
Updated on 24-Jan-2023 19:23:03

2K+ Views

The ps command in Linux is used to display information about the running processes on a system. It provides a snapshot of the current processes, including the process ID (PID), the user that owns the process, the percentage of CPU and memory usage, and the command that started the process. By default, ps only shows information about processes that are running in the same terminal session as the ps command. However, using various options and command line arguments, you can customize the output to show information about all processes running on the system, or even remotely. Listing All Processes To ... Read More

Introduction to Bash Globbing on Linux

Satish Kumar
Updated on 24-Jan-2023 19:21:57

2K+ Views

Bash globbing is the process of using wildcard characters to match multiple filenames or paths. Bash provides several special characters that can be used for globbing, such as *, ?, and []. The * character is a wildcard that can match zero or more characters in a filename or path. For example, the command ls * would list all files in the current directory, while the command ls *.txt would list all files with the ".txt" extension in the current directory. The ? character is similar to the * character, but it only matches a single character. For example, the ... Read More

Find and Convert Files Ending with CRLF on Linux

Satish Kumar
Updated on 24-Jan-2023 19:20:20

14K+ Views

You can use the find command in Linux to search for files ending with CRLF, and the dos2unix command to convert those files to use LF line endings. To search for files ending with CRLF, you can use the following command − find /path/to/search -type f -exec grep -Iq . {} \; -and -exec grep -Il $'\r' {} + This command searches for all regular files in the directory "/path/to/search" and its subdirectories, and prints the names of the files that contain CRLF line endings. Once you have identified the files that need to be converted, you can use ... Read More

Generate IP Addresses from CIDR Address Using Python

Vikram Chiluka
Updated on 24-Jan-2023 19:18:42

5K+ Views

In this article, we will learn how to generate IP addresses from the CIDR address. Methods Used The following are the various methods to accomplish this task − Generating IPv4 Network addresses Generating IPv6 Network addresses Accessing IP addresses of the CIDR address Method 1: IPv4Network Algorithm (Steps) Following are the Algorithms/steps to be followed to perform the desired task. − Use the import keyword to Import the ipaddress module. Use the ip_network() function(returns the type of network of the address ) of ipaddress module to get the IP addresses from an input CIDR address(IPv4Network) Use the ... Read More

Find Profit or Loss Using Python When CP of N Items Equals SP of M

Vikram Chiluka
Updated on 24-Jan-2023 19:13:18

599 Views

In this article, we will learn a python program to find the profit or loss when the cost price CP of N items is equal to the selling price SP of M items. Assume we have taken N, and M values which represent the cost price of N items are equal to the selling price of M items. We will now calculate the profit or loss percentage. Formula profit/loss = ( (Cost Price) - (Selling Price) ) / (Selling Price) * 100 What is the Selling Price(SP)? The price a consumer pays to purchase a product or a commodity ... Read More

Determine Last Friday's Date Using Python

Vikram Chiluka
Updated on 24-Jan-2023 19:12:10

4K+ Views

In this article, we will learn how to determine last Friday’s Date using Python. Methods Used The following are the various methods to accomplish this task − Using datetime module Using dateutil package Method 1: Using Datetime Module Algorithm (Steps) Following are the Algorithm/steps to be followed to perform the desired task. − Use the import keyword to import the datetime, timedelta from datetime module. Create a variable to store the list of all the days in a week(weekdays). Create a function getPreviousByDay() to return the last weekday of the input day by accepting the input day, ... Read More

Detect Whether a Python Variable is a Function

Vikram Chiluka
Updated on 24-Jan-2023 19:10:46

6K+ Views

In this article, we will learn how to detect whether a Python variable is a function. Sometimes, it is essential to figure out whether or not a Python variable is a function. When the code is a thousand lines long and you are not the creator of the code, this may appear to be of little value, and you may find yourself questioning if a variable is a function or not. Methods Used The following are the methods to check whether a python variable is a function − Using the built-in callable() function Using the isfunction() of the ... Read More

Create a Dictionary of Sets in Python

Vikram Chiluka
Updated on 24-Jan-2023 19:08:33

3K+ Views

In this article, we will learn how to create a dictionary of sets in Python. Methods Used The following are the various methods used to accomplish this task − Using the Naive Method Using defaultdict() Method Using setdefault() Method Method 1: Using the Naive Method In this method, we create a dictionary of sets by passing sets as values to the keys. Syntax { ‘Key’: Set 1, ‘Key’:Set 2, ………….., ’Key’: Set n} Algorithm (Steps) Following are the Algorithms/steps to be followed to perform the desired task. − Create a variable to store the dictionary containing ... Read More

Align Text Strings Using Python

Vikram Chiluka
Updated on 24-Jan-2023 19:02:30

35K+ Views

In this article, we will learn how to align text strings using Python. We will be using f-strings for this aligning text strings in python. Python's Text Alignment feature is helpful for printing output that is well and cleanly formatted. Sometimes the length of the data to be printed varies, making it appear untidy when printed. By specifying the alignment as left, right, or center and the space (width) to reserve for the string, the output string can be aligned using String Alignment. The text will be formatted using the f-strings. The output string's alignment is defined by the symbols ... Read More

Difference Between Manifest Functions and Latent Functions

Vineet Nanda
Updated on 24-Jan-2023 15:38:15

5K+ Views

Separating "conscious impulses for social activities, and their objective implications, " or, as Robert Merton puts it elsewhere, "obvious factual repercussions of intuitive tendencies, " is what Robert Merton called the distinction between manifest and latent functions. What is Manifest Function? In Merton's view, the phrase "manifest function" denotes the intent behind social laws, processes, or activities that are designed to improve society. Manifest functions, he argued further, are the overt goals of social institutions. What is a Latent Function? Latent functions, on the other hand, are those that people don't realize they're doing but that have positive social effects. ... Read More

Advertisements