tail

Prints the end of the file, the opposite of the head option.

TAIL(1) BSD General Commands Manual

NAME
     tail -- display the last part of a file

SYNOPSIS
     tail [-F | -f | -r] [-q] [-b number | -c number | -n number] [file ...].

github

  • The file in jupyter notebook format on github is here.

google colaboratory

  • To run it in google colaboratory here /tail_nb.ipynb)

environment

The author’s OS is macOS, and the options are different from those of Linux and Unix commands.

If you want to run the command in real life, you should use the prefix ! and %%bash in the first line.

!sw_vers
``` ProductName: Mac OS X

    ProductName: Mac OS X
    ProductVersion: 10.14.6
    BuildVersion: 18G2022



```python
!bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
Copyright (C) 2007 Free Software Foundation, Inc.

Example usage

%%bash
echo "Preparing the file"
echo -e "1\n2 \n3 \n4 \n5 \n6" > temp
cat temp

echo -e "\n<print the last 3 lines of the file>"
tail -n 3 temp
Prepare the file
1
2
3
4
5
6

<display the last 3 lines of the file>.
4
5
6

Typical options

  • n : number of lines to display