# RANDOM shell scripting question

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

## 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 on other sites
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.

1. 1
2. 2
3. 3
frob
20
4. 4
Rutin
19
5. 5

• 32
• 13
• 10
• 9
• 18
• ### Forum Statistics

• Total Topics
632555
• Total Posts
3007065

×