Found 353 Questions for Linux

How to preserve colouring after piping grep to grep in Linux?

Mukul Latiyan
Updated on 30-Jul-2021 09:05:57
In order to be able to preserve colouring after using the pipe in between the grep togrep command, we must first be aware of what the 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 ... Read More

How to perform grep operation on all files in a directory?

Mukul Latiyan
Updated on 30-Jul-2021 09:04:32
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

How to match two strings that are present in one line with grep in Linux?

Mukul Latiyan
Updated on 30-Jul-2021 09:03:21
In order to be able to grep two strings that exists on the same line in Linux command line, 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 ... Read More

How to list running screen sessions on Linux?

Mukul Latiyan
Updated on 30-Jul-2021 09:02:15
Screen or sometimes also known as GNU Screen, is a terminal multiplexer. What it means is that it allows you the privilege to start a screen session and then open any number of windows inside that session.It might also be interesting to note that a process that is running in Screen will continue to run even when their window is not visible anymore.Installing Linux ScreenIn order to install the screen package if it is not already present on your Linux distribution, you can run any of the suitable commands shown below for your machine.For Ubuntu and Debiansudo apt update sudo ... Read More

How to list down all the available commands and aliases on Linux?

Mukul Latiyan
Updated on 30-Jul-2021 09:01:18
Linux provides us with a huge amount of commands along with their aliases that we can make use of. Although these commands serve different purposes we can still make use of all these commands anywhere we like in the terminal.There are different ways with which we can interact with Linux commands. When it comes to listing all the available commands to the terminal we also have different approaches, either we can write a shell script by ourselves or we can use a shell library function that does that for us.Let’s consider the first approaches where I'll make use of a ... Read More

How to list all users in a Linux group?

Mukul Latiyan
Updated on 30-Jul-2021 08:59:51
In order to be able to understand the command to list all the users that are present in a Linux group, you first must be able to print all the users present.For that there are many different possible ways, I’ll make use of the compgen command. The compgen command is a Linux utility command that is used to list all the commands that can be executed in a Linux terminal, and when used with a -u flag we can simply print all the users present on Linux.Consider the command shown below as reference −compgen -uOutputroot daemon bin sys sync games man ... Read More

How to limit the number of results returned from grep in Linux?

Mukul Latiyan
Updated on 30-Jul-2021 08:58:49
In order to be able to grep limit the number of results returned from grep command in Linux, 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 ... Read More

How to know what the ‘errno’ means in Linux?

Mukul Latiyan
Updated on 30-Jul-2021 08:54:44
Errno is a value that you get when the command you run returns the value of the call indicating an error. There is a header file that defines the integer variable errno, which is set by the system calls and some library function in the event of an error to let the developer know what’s wrong.In simple terms, the “errnos” are symptoms of operating system errors. Generally produced by failed operating system calls.In UNIX, the errnos are defined in upper case letters.ExampleEPERM ENOENT ESRCH EINTR EIO ENXIOIn the above examples, some formatted errnos are mentioned that have different values and ... Read More

How to iterate over a list of files with spaces in Linux?

Mukul Latiyan
Updated on 30-Jul-2021 08:49:46
In order to iterate over a list of files we will need to make use of the find command that Linux provides us with.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 ... Read More

How to invert a grep expression on Linux?

Mukul Latiyan
Updated on 30-Jul-2021 08:47:14
In order to be able to invert a grep expression on Linux command line, 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
Previous 1 ... 5 6 7 8 9 10 11 ... 36 Next
Advertisements