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?

link|improve this question
Does the more formal ls -1tr | tail -n 1 work? – p.vitzliputzli Mar 13 '11 at 18:03
feedback

1 Answer

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.

link|improve this answer
1  
Corrected it! Thank you! – p.vitzliputzli Mar 13 '11 at 20:05
1  
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
1  
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
1  
Yes, I would try that with the default installation. – p.vitzliputzli Mar 14 '11 at 14:00
1  
Maybe you have to change the PATH-var in Windows to your new cygwin installation. – p.vitzliputzli Mar 14 '11 at 15:34
show 9 more comments
feedback

Your Answer

 
or
required, but never shown

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