{
    "content": [
        {
            "type": "text",
            "text": "# tail (info)\n\n## Sections\n\n- **File: coreutils.info,  Node: tail invocation,  Next: split invocation,  Prev: head invocation,  Up: Output of parts of files** (1 subsections)\n- **For example, avoid 'tail - main.c', since it might be interpreted as**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "tail",
        "section": "",
        "mode": "info",
        "summary": null,
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "File: coreutils.info,  Node: tail invocation,  Next: split invocation,  Prev: head invocation,  Up: Output of parts of files",
                "lines": 1,
                "subsections": [
                    {
                        "name": "5.2 'tail': Output the last part of files",
                        "lines": 216
                    }
                ]
            },
            {
                "name": "For example, avoid 'tail - main.c', since it might be interpreted as",
                "lines": 7,
                "subsections": []
            }
        ],
        "sections": {
            "File: coreutils.info,  Node: tail invocation,  Next: split invocation,  Prev: head invocation,  Up: Output of parts of files": {
                "content": "",
                "subsections": [
                    {
                        "name": "5.2 'tail': Output the last part of files",
                        "content": "'tail' prints the last part (10 lines by default) of each FILE; it reads\nfrom standard input if no files are given or when given a FILE of '-'.\nSynopsis:\n\ntail [OPTION]... [FILE]...\n\nIf more than one FILE is specified, 'tail' prints a one-line header\nbefore the output for each FILE, consisting of:\n\n==> FILE NAME <==\n\nFor further processing of tail output, it can be useful to convert\nthe file headers to line prefixes, which can be done like:\n\ntail ... |\nawk '\n/^==> .* <==$/ {prefix=substr($0,5,length-8)\":\"; next}\n{print prefix$0}\n' | ...\n\nGNU 'tail' can output any amount of data (some other versions of\n'tail' cannot).  It also has no '-r' option (print in reverse), since\nreversing a file is really a different job from printing the end of a\nfile; BSD 'tail' (which is the one with '-r') can only reverse files\nthat are at most as large as its buffer, which is typically 32 KiB.  A\nmore reliable and versatile way to reverse files is the GNU 'tac'\ncommand.\n\nThe program accepts the following options.  Also see *note Common\noptions::.\n\n'-c [+]NUM'\n'--bytes=[+]NUM'\nOutput the last NUM bytes, instead of final lines.  If NUM is\nprefixed with a '+', start printing with byte NUM from the start of\neach file.  For example to skip the first byte use 'tail -c +2',\nwhile to skip all but the last byte use 'tail -c 1'.  NUM may be,\nor may be an integer optionally followed by, one of the following\nmultiplicative suffixes:\n'b'  =>            512 (\"blocks\")\n'KB' =>           1000 (KiloBytes)\n'K'  =>           1024 (KibiBytes)\n'MB' =>      1000*1000 (MegaBytes)\n'M'  =>      1024*1024 (MebiBytes)\n'GB' => 1000*1000*1000 (GigaBytes)\n'G'  => 1024*1024*1024 (GibiBytes)\nand so on for 'T', 'P', 'E', 'Z', 'Y', 'R', and 'Q'.  Binary\nprefixes can be used, too: 'KiB'='K', 'MiB'='M', and so on.\n\n'-f'\n'--follow[=HOW]'\nLoop forever trying to read more characters at the end of the file,\npresumably because the file is growing.  If more than one file is\ngiven, 'tail' prints a header whenever it gets output from a\ndifferent file, to indicate which file that output is from.\n\nThere are two ways to specify how you'd like to track files with\nthis option, but that difference is noticeable only when a followed\nfile is removed or renamed.  If you'd like to continue to track the\nend of a growing file even after it has been unlinked, use\n'--follow=descriptor'.  This is the default behavior, but it is not\nuseful if you're tracking a log file that may be rotated (removed\nor renamed, then reopened).  In that case, use '--follow=name' to\ntrack the named file, perhaps by reopening it periodically to see\nif it has been removed and recreated by some other program.  Note\nthat the inotify-based implementation handles this case without the\nneed for any periodic reopening.\n\nNo matter which method you use, if the tracked file is determined\nto have shrunk, 'tail' prints a message saying the file has been\ntruncated and resumes tracking from the start of the file, assuming\nit has been truncated to 0, which is the usual truncation operation\nfor log files.\n\nWhen a file is removed, 'tail''s behavior depends on whether it is\nfollowing the name or the descriptor.  When following by name, tail\ncan detect that a file has been removed and gives a message to that\neffect, and if '--retry' has been specified it will continue\nchecking periodically to see if the file reappears.  When following\na descriptor, tail does not detect that the file has been unlinked\nor renamed and issues no message; even though the file may no\nlonger be accessible via its original name, it may still be\ngrowing.\n\nThe option values 'descriptor' and 'name' may be specified only\nwith the long form of the option, not with '-f'.\n\nThe '-f' option is ignored if no FILE operand is specified and\nstandard input is a FIFO or a pipe.  Likewise, the '-f' option has\nno effect for any operand specified as '-', when standard input is\na FIFO or a pipe.\n\nWith kernel inotify support, output is triggered by file changes\nand is generally very prompt.  Otherwise, 'tail' sleeps for one\nsecond between checks - use '--sleep-interval=N' to change that\ndefault - which can make the output appear slightly less responsive\nor bursty.  When using tail without inotify support, you can make\nit more responsive by using a sub-second sleep interval, e.g., via\nan alias like this:\n\nalias tail='tail -s.1'\n\n'-F'\nThis option is the same as '--follow=name --retry'.  That is, tail\nwill attempt to reopen a file when it is removed.  Should this\nfail, tail will keep trying until it becomes accessible again.\n\n'--max-unchanged-stats=N'\nWhen tailing a file by name, if there have been N (default n=5)\nconsecutive iterations for which the file has not changed, then\n'open'/'fstat' the file to determine if that file name is still\nassociated with the same device/inode-number pair as before.  When\nfollowing a log file that is rotated, this is approximately the\nnumber of seconds between when tail prints the last pre-rotation\nlines and when it prints the lines that have accumulated in the new\nlog file.  This option is meaningful only when polling (i.e.,\nwithout inotify) and when following by name.\n\n'-n [+]NUM'\n'--lines=[+]'\nOutput the last NUM lines.  If NUM is prefixed with a '+', start\nprinting with line NUM from the start of each file.  For example to\nskip the first line use 'tail -n +2', while to skip all but the\nlast line use 'tail -n 1'.  Size multiplier suffixes are the same\nas with the '-c' option.\n\n'--pid=PID'\nWhen following by name or by descriptor, you may specify the\nprocess ID, PID, of the sole writer of all FILE arguments.  Then,\nshortly after that process terminates, tail will also terminate.\nThis will work properly only if the writer and the tailing process\nare running on the same machine.  For example, to save the output\nof a build in a file and to watch the file grow, if you invoke\n'make' and 'tail' like this then the tail process will stop when\nyour build completes.  Without this option, you would have had to\nkill the 'tail -f' process yourself.\n\n$ make >& makerr & tail --pid=$! -f makerr\n\nIf you specify a PID that is not in use or that does not correspond\nto the process that is writing to the tailed files, then 'tail' may\nterminate long before any FILEs stop growing or it may not\nterminate until long after the real writer has terminated.  Note\nthat '--pid' cannot be supported on some systems; 'tail' will print\na warning if this is the case.\n\n'-q'\n'--quiet'\n'--silent'\nNever print file name headers.\n\n'--retry'\nIndefinitely try to open the specified file.  This option is useful\nmainly when following (and otherwise issues a warning).\n\nWhen following by file descriptor (i.e., with\n'--follow=descriptor'), this option only affects the initial open\nof the file, as after a successful open, 'tail' will start\nfollowing the file descriptor.\n\nWhen following by name (i.e., with '--follow=name'), 'tail'\ninfinitely retries to re-open the given files until killed.\n\nWithout this option, when 'tail' encounters a file that doesn't\nexist or is otherwise inaccessible, it reports that fact and never\nchecks it again.\n\n'-s NUMBER'\n'--sleep-interval=NUMBER'\nChange the number of seconds to wait between iterations (the\ndefault is 1.0).  During one iteration, every specified file is\nchecked to see if it has changed size.  When 'tail' uses inotify,\nthis polling-related option is usually ignored.  However, if you\nalso specify '--pid=P', 'tail' checks whether process P is alive at\nleast every NUMBER seconds.  The NUMBER must be non-negative and\ncan be a floating-point number in either the current or the C\nlocale.  *Note Floating point::.\n\n'-v'\n'--verbose'\nAlways print file name headers.\n\n'-z'\n'--zero-terminated'\nDelimit items with a zero byte rather than a newline (ASCII LF).\nI.e., treat input as items separated by ASCII NUL and terminate\noutput items with ASCII NUL. This option can be useful in\nconjunction with 'perl -0' or 'find -print0' and 'xargs -0' which\ndo the same in order to reliably handle arbitrary file names (even\nthose containing blanks or other special characters).\n\nFor compatibility 'tail' also supports an obsolete usage 'tail\n-[NUM][bcl][f] [FILE]', which is recognized only if it does not conflict\nwith the usage described above.  This obsolete form uses exactly one\noption and at most one file.  In the option, NUM is an optional decimal\nnumber optionally followed by a size letter ('b', 'c', 'l') to mean\ncount by 512-byte blocks, bytes, or lines, optionally followed by 'f'\nwhich has the same meaning as '-f'.\n\nOn systems not conforming to POSIX 1003.1-2001, the leading '-' can\nbe replaced by '+' in the traditional option syntax with the same\nmeaning as in counts, and on obsolete systems predating POSIX\n1003.1-2001 traditional usage overrides normal usage when the two\nconflict.  This behavior can be controlled with the 'POSIX2VERSION'\nenvironment variable (*note Standards conformance::).\n\nScripts intended for use on standard hosts should avoid traditional\nsyntax and should use '-c NUM[b]', '-n NUM', and/or '-f' instead.  If\nyour script must also run on hosts that support only the traditional\nsyntax, you can often rewrite it to avoid problematic usages, e.g., by\nusing 'sed -n '$p'' rather than 'tail -1'.  If that's not possible, the\nscript can use a test like 'if tail -c +1 </dev/null >/dev/null 2>&1;\nthen ...' to decide which syntax to use.\n\nEven if your script assumes the standard behavior, you should still\nbeware usages whose behaviors differ depending on the POSIX version."
                    }
                ]
            },
            "For example, avoid 'tail - main.c', since it might be interpreted as": {
                "content": "either 'tail main.c' or as 'tail -- - main.c'; avoid 'tail -c 4', since\nit might mean either 'tail -c4' or 'tail -c 10 4'; and avoid 'tail +4',\nsince it might mean either 'tail ./+4' or 'tail -n +4'.\n\nAn exit status of zero indicates success, and a nonzero value\nindicates failure.\n",
                "subsections": []
            }
        }
    }
}