Featured Post

Python Regex: The 5 Exclusive Examples

 Regular expressions (regex) are powerful tools for pattern matching and text manipulation in Python. Here are five Python regex examples with explanations: 01 Matching a Simple Pattern import re text = "Hello, World!" pattern = r"Hello" result = re.search(pattern, text) if result:     print("Pattern found:", result.group()) Output: Output: Pattern found: Hello This example searches for the pattern "Hello" in the text and prints it when found. 02 Matching Multiple Patterns import re text = "The quick brown fox jumps over the lazy dog." patterns = [r"fox", r"dog"] for pattern in patterns:     if re.search(pattern, text):         print(f"Pattern '{pattern}' found.") Output: Pattern 'fox' found. Pattern 'dog' found. It searches for both "fox" and "dog" patterns in the text and prints when they are found. 03 Matching Any Digit   import re text = "The price of the

Tail Command in Linux: A Comprehensive Overview

The tail in Linux is handy command. You can check the last lines of a file in Linux/Unix operating systems.

You can use it to display last lines from single file, display last lines from multiple files, display the last entries of log files.

Tail Command in Linux

During production support the usage of Tail command is helpful since you can check latest logs quickly. Here are the top Tail command examples.

#1 Display last lines in a file (Tail file Linux)

Here's the tail command that shows last three lines of a file.

cat sample.txt | tail -3

It displays last 3 lines of a file. The same command you can use as

tail -3 sample.txt

#2 Display last lines of multiple files

There are three files. sample2.txt, sample3.txt, sample4.txt. The command displays the last 3 lines from all the three files.

tail -3 sample[2-4].txt

Tail command

#3 Tail -f option (Tail f Linux)

The –f option is to check status of long-running process that is redirecting output to a file. For example, if you invoke the below command, the status it writes to the output.

find . -print |xargs grep -i abc </tmp/abc &

Using the -f option you can see contents of the file /tmp/abc whenever it is updated: 

tail -f /tmp/abc




Popular posts from this blog

Explained Ideal Structure of Python Class

6 Python file Methods Real Usage

How to Decode TLV Quickly