Featured Post

How to Compare Text in Python

Image
Python like other programming languages supports comparison operators. These primarily use to test the condition in the program. Here's a list of operators that you can use in python programs. Comparison operators List of operators < <= > >= == != Is is not How to use comparison operators Here, I have assigned 23 to a and 11 to b. Then, I did apply all the comparison operators. The output is self-explanatory, and If you are in doubt while programming, remember to visit this page. Examples a = 23 b = 11 print("Is a greater than b?", a > b)           #greater than print("Is a less than b?", a < b)              #less than print("Is a greater or equal to b?", a >= b)   #greater or equal print("Is a less or equal to b?", a <= b)      #less or equal print("Is a equal to b (option 1)?", a == b)         #test for equality print("Is a equal to b (option 2)?", a is b)         #test for equality print("I

How to Use Tail Command in Linux

Here's a way that shows how to use tail command in Linux. The uses are VIZ: display last lines from single file, display last lines from multiple files, display the last entries of log files.

The tail is handy command and popular to check last lines of a file in Linux/Unix operating systems.

Tail Command in Linux

While working with files and production support the usage of tail command is helpful. Here are the selected examples that how you can use effectively.

1. Display last lines in a file

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 

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

Comments

Popular posts from this blog

7 AWS Interview Questions asked in Infosys, TCS

How to Decode TLV Quickly

Hyperledger Fabric: 20 Real Interview Questions