Tag Archives: grep examples

command grep examples in linux

The grep command in Linux is indispensable for filtering and searching through text. Here are some practical examples of how to use grep in different scenarios: These examples showcase the flexibility and power of grep for text searching and data … Continue reading

Posted in File & Directory, Grep Command | Tagged , , | Comments Off on command grep examples in linux

linux grep pattern

In Linux, the grep command is used to search for a specific pattern in the input. When you want to search for a pattern in files or output from other commands, here’s how you can use grep: Remember to replace … Continue reading

Posted in File & Directory, Grep Command | Tagged , , | Comments Off on linux grep pattern

Linux `ls` and `grep` Command Usage: 10 Practical Examples

In Linux, you can use a combination of the ls and grep commands to filter the output of ls based on specific patterns or strings. This is particularly useful for searching through directory contents for files that match certain criteria. … Continue reading

Posted in File & Directory, Ls Command | Tagged , , , , | Comments Off on Linux `ls` and `grep` Command Usage: 10 Practical Examples

How to fast search for specified content in large files in linux

In linux, to search for specified content in large files, we can use tail -c or head -c commands. Continue reading

Posted in File & Directory, Text Processing | Tagged , , , | Comments Off on How to fast search for specified content in large files in linux

How to find all files containing specific text on Linux?

In linux, to find all files containing a specific text, we can use the grep command, which can search for the specified text in the file. In the following example, we will introduce two methods to find all files containing … Continue reading

Posted in Find Command | Tagged , , | Comments Off on How to find all files containing specific text on Linux?

How to delete empty lines in a text file in linux/unix

To delete blank lines in a text file, you can use awk NF variable, awk regular expression, sed regular expression and grep -v ‘^$’ Continue reading

Posted in How to, Awk Command, Sed Command, Text Processing | Tagged , , , | Comments Off on How to delete empty lines in a text file in linux/unix

How to delete lines containing a specific string in a text file in linux/unix

Delete lines containing a specific string in a text file, we have three implementation methods: sed -i ‘/ pattern/d’, grep -v ‘pattern’ and awk ‘!/pattern/ {print $0}’ Continue reading

Posted in Text Processing, Awk Command, How to, Sed Command | Tagged , , , | Comments Off on How to delete lines containing a specific string in a text file in linux/unix

grep command tutorial in linux/unix with examples and use cases

linux grep command – print lines that match patterns Linux grep searches for PATTERNS in each FILE. PATTERNS is one or patterns separated by newline characters, and grep prints each line that matches a pattern. A FILE of “-” stands … Continue reading

Posted in File & Directory | Tagged , , | Comments Off on grep command tutorial in linux/unix with examples and use cases

AWK tutorial: find and kill process use awk

Step 1. View the process ID pid of the top command.
Step 2. Use the awk command to get the process ID.
Step 3. Use xargs kill to kill top process ID. Continue reading

Posted in Awk Command, Text Processing | Tagged , , , | 1 Comment

grep multiple words/patterns/strings, and/or condition, use -e or regex

grep multiple words

You can use grep -e parameters and pipes (“|”) to implement grep multiple words “and” query, “or” query … Continue reading

Posted in File & Directory | Tagged , , | Comments Off on grep multiple words/patterns/strings, and/or condition, use -e or regex

linux grep process by name/by id and kill example, and grep -v example

linux grep process

– grep process name;
– grep process by port;
– grep process id and kill;
– grep process without itself;
– grep process without grep
Continue reading

Posted in File & Directory | Tagged , , , | Comments Off on linux grep process by name/by id and kill example, and grep -v example

How to count using the grep command in Linux/Unix

linux grep count * ; – grep count lines; – grep count words; – grep count files; – grep count sort; – grep two words on the same line …… Continue reading

Posted in File & Directory, How to | Tagged , , | Comments Off on How to count using the grep command in Linux/Unix

linux grep command – grep not include, grep reverse match

There is also a case where we need to exclude certain content when we do content search. How to achieve it? Still linux grep command! I have such a file test5.txt. Need to query the line containing “dfff” content but … Continue reading

Posted in File & Directory | Tagged , , | Comments Off on linux grep command – grep not include, grep reverse match

linux grep command – grep only show match

When we search for content, sometimes we just need to show matching content. At this time we can use the grep command. linux grep You can also display the line number where the matching content is located. linux grep -n … Continue reading

Posted in File & Directory | Tagged , , , | Comments Off on linux grep command – grep only show match

linux grep command – grep multiple patterns

The last article 《grep or condition, grep and condition》 introduced grep and, or use, including the use of the -e parameter. Here is a detailed description of the use of the -e parameter. grep one pattern ➜ grep “12” test1.txt … Continue reading

Posted in File & Directory | Tagged , , , | Comments Off on linux grep command – grep multiple patterns