Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a weird situation here... two out of three of my servers refuse to give any output to the command ls -1tr | tail -1

There are definitely files in the directory but it gives no output what so ever (returns nothing and goes back to the prompt)... simply typing ls or ls -c works but not ls -1tr | tail -1

x2 Server 2003

x1 Server 2008

Only one of the Server 2003 gives the correct response to the command.

I have put the /bin directory in the windows environmental path field so I don't think that is the problem.

Any suggestions?

share|improve this question
Does the more formal ls -1tr | tail -n 1 work? – p.vitzliputzli Mar 13 '11 at 18:03
up vote 3 down vote accepted

The tail -[number] syntax is no longer valid by POSIX.1-2008. Maybe you are using different versions of the coreutils and that is why you are experiencing different results. The correct syntax is ls -1tr | tail -n 1.

share|improve this answer
Corrected it! Thank you! – p.vitzliputzli Mar 13 '11 at 20:05
Besides from trying to upgrade your cygwin installations, you could try to use ls -1tr | tail --lines=1. – p.vitzliputzli Mar 13 '11 at 20:54
Errno 22 is probably EINVAL, i.e. invalid argument. It sounds like you have encountered a cygwin bug. Nevertheless, could you please post the coreutils/tail-version? tail --version – p.vitzliputzli Mar 14 '11 at 11:46
Yes, I would try that with the default installation. – p.vitzliputzli Mar 14 '11 at 14:00
Maybe you have to change the PATH-var in Windows to your new cygwin installation. – p.vitzliputzli Mar 14 '11 at 15:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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