Featured Post

Top Questions People Ask About Pandas, NumPy, Matplotlib & Scikit-learn — Answered!

Image
 Whether you're a beginner or brushing up on your skills, these are the real-world questions Python learners ask most about key libraries in data science. Let’s dive in! 🐍 🐼 Pandas: Data Manipulation Made Easy 1. How do I handle missing data in a DataFrame? df.fillna( 0 ) # Replace NaNs with 0 df.dropna() # Remove rows with NaNs df.isna(). sum () # Count missing values per column 2. How can I merge or join two DataFrames? pd.merge(df1, df2, on= 'id' , how= 'inner' ) # inner, left, right, outer 3. What is the difference between loc[] and iloc[] ? loc[] uses labels (e.g., column names) iloc[] uses integer positions df.loc[ 0 , 'name' ] # label-based df.iloc[ 0 , 1 ] # index-based 4. How do I group data and perform aggregation? df.groupby( 'category' )[ 'sales' ]. sum () 5. How can I convert a column to datetime format? df[ 'date' ] = pd.to_datetime(df[ 'date' ]) ...

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

5 SQL Queries That Popularly Used in Data Analysis

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