Hide

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Hide

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

A faster ls

Terminal - A faster ls
echo *
2009-04-17 21:40:58
User: kFiddle
Functions: echo
-5
A faster ls

Sometimes "ls" is just too slow, especially if you're having problems with terminal scroll speed, or if you're a speed freak. In these situations, do an echo * in the current directory to immediately see the directory listing. Do an echo * | tr ' ' '\n' if you want a column. Do an alias ls='echo *' if you want to achieve higher echelons of speed and wonder. Note that echo * is also useful on systems that are so low in memory that "ls" itself is failing - perhaps due to a memory leak that you're trying to debug.

Alternatives

There is 1 alternative - vote for the best!

Terminal - Alternatives

Know a better way?

If you can do better, submit your command here.

What others think

Yes, it'll print all filenames quite fast, all in one line, and the use of tr(1) won't work if there's (ugh) spaces in filenames. Also, mapping ls to "echo *" is not a good idea at all. Too many scripts depend on such a vital command as ls(1) and will break in some way or another. Things stored in /bin/ are essential on a *NIX system and should not be tampered with.

Comment by sunny32768 275 weeks ago

This might get you out of a scrape in rare circumstances.. but don't alias it! In addition to the previous posters comments, this *will* fail on directories that contain many files as the wildcard will expand beyond the size of the shell parser's command line buffer.

Comment by animoid 275 weeks ago

Too much typing, and what are you gaining really? Is your hardware that slow that you notice the difference?

Comment by atoponce 275 weeks ago

Here's what you gain:

ls

real 0m0.007s

user 0m0.000s

sys 0m0.008s

echo *

real 0m0.002s

user 0m0.000s

sys 0m0.004s

echo * | tr ' ' '\n'

real 0m0.008s

user 0m0.004s

sys 0m0.004s

I don't notice it much...

Comment by brie 232 weeks ago

Timings using an Intel(R) Core(TM)2 Quad CPU Q8200 @ 2.33GHz - Ubuntu 9.10 Karmic 64bit

using bash in gnome-terminal:

ls /usr/lib/

real 0m0.563s

user 0m0.030s

sys 0m0.010s

echo /usr/lib/*

real 0m0.086s

user 0m0.020s

sys 0m0.000s

using bash on first console (the infamous Ctrl+F1)

ls provide 0.25s

echo provide 0.024s

seems that "ls" output time is about 6 times "echo" output time

To me prove that echo is faster than ls in pseudo-pure computational time (in bash on gnome-terminal)...better values on first console (echo is 10 times faster than ls)

I disagree totally about aliasing ls due to it's own obvious conclusion in terms of pipings issues.

I found this solution very interesting when I have to simply parse folder content in term of pure strings.

Comment by LucaCappelletti 231 weeks and 3 days ago

Your point of view

You must be signed in to comment.

Related sites and podcasts