Featured Post

Python Set Operations Explained: From Theory to Real-Time Applications

Image
A  set  in Python is an unordered collection of unique elements. It is useful when storing distinct values and performing operations like union, intersection, or difference. Real-Time Example: Removing Duplicate Customer Emails in a Marketing Campaign Imagine you are working on an email marketing campaign for your company. You have a list of customer emails, but some are duplicated. Using a set , you can remove duplicates efficiently before sending emails. Code Example: # List of customer emails (some duplicates) customer_emails = [ "alice@example.com" , "bob@example.com" , "charlie@example.com" , "alice@example.com" , "david@example.com" , "bob@example.com" ] # Convert list to a set to remove duplicates unique_emails = set (customer_emails) # Convert back to a list (if needed) unique_email_list = list (unique_emails) # Print the unique emails print ( "Unique customer emails:" , unique_email_list) Ou...

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


Related

References

Comments

Popular posts from this blog

SQL Query: 3 Methods for Calculating Cumulative SUM

Big Data: Top Cloud Computing Interview Questions (1 of 4)

5 SQL Queries That Popularly Used in Data Analysis