• Advertisement
Sign in to follow this  

RANDOM shell scripting question

This topic is 4234 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm not sure if this is the appropriate place to ask this question, but here I go... In unix shell scripting, I just noticed that if I enter "ls" in a directory containing 28000+ files it takes a LONG time for the output to appear. However, if I do something like this: > ls | grep "" It happens almost instantly. Same goes for something like this: > echo `ls` (note the grave accents). Can anyone explain why these 2 methods are so much faster that a simple "ls"? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Not knowing what ls implementation and what shell you are using, I'd have to guess that the slow down when you are using ls by itself is that the shell the time to read in the entire directory contents and the formats the output by column. When ls is piped to another application it just writes as fast as it reads the entries.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement