Saturday, 9 June 2018

Filters and commands: Tail command in Unix systems with examples

The tail command, as the name refers that it display the last N lines of given input content. By default, the value of N is 10 lines. While no option is mentioned in command then it display last 10 lines of the file content.

~$ man tail   (on Linux ubuntu 16.10)
 





~$cat testfile4      // display content of testfile4
~$ tail -5 testfile4   // displays last five lines of the content of the file
~$ awk 'END { print NR }' testfile4   // no of lines in testfile4
~$ tail -n +14 testfile4   // displays last 7 lines starting from the line No. 14
~$ tail -c -5 testfile4   // displays last five bytes of the file
~$ tail -c +100 testfile4   // displays last 23 bytes starting from the byte No. 100




~$tail -f testfile3      // display live content of testfile3 (logfile)

In case, if user want to see log content of log-file of some currently running process. For example, Android studio log file is generated and can be seen while App is debugging.

No comments:

Post a Comment

UGC NET Computer Science December 2019 | Question 16

Question 16 In a certain coding language. 'AEIOU' is written as 'TNHDZ'. Using the same coding language. 'BFJPV' wil...

Popular Posts