[Lowerbounds, Upperbounds]

Algorithms are everywhere.

You would think that there must be a utility in Unix like head or tail that would chop off the first few lines of a file and output the rest. Well, I haven’t found it yet.

In any case, perl worked.

cat foo.txt | perl -e "print splice @{[<>]}, 5″

5 Comments

  1. AvatarSuresh
    18:42 on June 30th, 2005

    tail +n returns all lines starting from line n. This combined with head, can give you any contiguous subinterval of the lines of a file

  2. Ah, that’s brilliant. Thanks!

  3. cat foo.txt | sed -e ‘1,5 d’

  4. AvatarAnonymous
    22:18 on June 30th, 2005

    cat foo.txt | awk ‘NR >= n’

    you can put more complex conditional expressions inside.

  5. AvatarBarak Pearlmutter
    16:22 on December 20th, 2005