0

I'm looking through some of the scripts that are on the servers and came across an 80MB shell script. Naturally curious I decided to look in there and came across this line:

tail +4802 $0 |
zcat - |
(cd $LANG_TMP &&
 tar -xf - loc/$LANGPRE$LANGPOST.po loc/poextract)  >>/dev/null 2>>/dev/null

Can someone give me a general gist of what this line is supposed to do? I've never seen a tail + command before, usually it's tail -.

  • 1
    Read the man page, it explains it there. – 123 Jun 25 '15 at 14:38
  • 4
    Probably your huge script is a shar like archive. Try tail --help & read tail(1) – Basile Starynkevitch Jun 25 '15 at 14:39
3

Using a plus means start printing from the nth line from the beginning of the file.

so +4802 will print from line 4802 till the end.

man tail gives you a manual page.

  • Interesting but when I actually try running tail +2 on a different file I get the following error: tail: cannot open `+2' for reading: No such file or directory – jabbajac Jun 25 '15 at 14:51
  • It might be a function in your script, invoking /usr/bin/tail – Basile Starynkevitch Jun 25 '15 at 14:57
  • well you have to give it a filename to read, or else it will assume stdin – X Tian Jun 25 '15 at 15:03
  • The command I gave was tail +2 testfile.txt and got the error: tail: cannot open `+2' for reading: No such file or directory. It does work with tail -n +2 testfile.txt though. – jabbajac Jun 25 '15 at 15:48
  • 1
    @jabbajac: Newer versions of the POSIX spec don't support the +42 and -42 arguments for tail; instead, you have to type -n +42 or -n -42. You can enable the older syntax with export _POSIX2_VERSION=199209. pubs.opengroup.org/onlinepubs/9699919799/utilities/tail.html – Keith Thompson Jun 25 '15 at 23:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.