Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try <a href="http://man7.org/linux/man-pages/man1/tail.1.html" rel="noreferrer">GNU tail</a>:</p> <pre><code>tail -n +2 "$FILE" </code></pre> <p><code>-n x</code>: Just print the last <code>x</code> lines. <code>tail -n 5</code> would give you the last 5 lines of the input. The <code>+</code> sign kind of inverts the argument and make <code>tail</code> print anything but the first <code>x-1</code> lines. <code>tail -n +1</code> would print the whole file, <code>tail -n +2</code> everything but the first line, etc.</p> <p>GNU <code>tail</code> is much faster than <code>sed</code>. <code>tail</code> is also available on BSD and the <code>-n +2</code> flag is consistent across both tools. Check the <a href="https://www.freebsd.org/cgi/man.cgi?query=tail" rel="noreferrer">FreeBSD</a> or <a href="https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/tail.1.html" rel="noreferrer">OS X</a> man pages for more. </p> <p>The BSD version can be much slower than <code>sed</code>, though. I wonder how they managed that; <code>tail</code> should just read a file line by line while <code>sed</code> does pretty complex operations involving interpreting a script, applying regular expressions and the like.</p> <p>Note: You may be tempted to use</p> <pre><code># THIS WILL GIVE YOU AN EMPTY FILE! tail -n +2 "$FILE" &gt; "$FILE" </code></pre> <p>but this will give you an <strong>empty file</strong>. The reason is that the redirection (<code>&gt;</code>) happens before <code>tail</code> is invoked by the shell:</p> <ol> <li>Shell truncates file <code>$FILE</code></li> <li>Shell creates a new process for <code>tail</code></li> <li>Shell redirects stdout of the <code>tail</code> process to <code>$FILE</code></li> <li><code>tail</code> reads from the now empty <code>$FILE</code></li> </ol> <p>If you want to remove the first line inside the file, you should use:</p> <pre><code>tail -n +2 "$FILE" &gt; "$FILE.tmp" &amp;&amp; mv "$FILE.tmp" "$FILE" </code></pre> <p>The <code>&amp;&amp;</code> will make sure that the file doesn't get overwritten when there is a problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload