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.


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.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.
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

May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!
Hide

Top Tags

Hide

Functions

Randomly run command

Terminal - Randomly run command
ran() { [ $((RANDOM%100)) -lt "$1" ] && shift && "[email protected]"; }
2015-07-16 13:32:45
User: flatcap
Functions: shift
5
Randomly run command

Randomly decide whether to run a command, or fail.

It's useful for testing purposes.

.

Usage: ran PERCENTAGE COMMAND [ARGS]

Note: In this version the percentage is required.

.

This is like @sesom42 and @snipertyler's commands but in a USABLE form.

.

e.g. In your complicated shell script, put "ran 99" before a crucial component.

Now, it will fail 1% of the time allowing you to test the failure code-path.

ran 99 my_complex_program arg1 arg2

Alternatives

There are 2 alternatives - vote for the best!

Terminal - Alternatives
ran() { R=$((RANDOM%100)); if [ $R -gt "${1:-50}" ]; then echo FALSE; false; else echo TRUE; true; fi; }
2015-07-15 15:34:56
User: snipertyler
Functions: echo
0

Command will succeed n% of the time.

ran 75 will cause command to succeed 75% of the time.

No argument will cause it to succeed 50% of the time.

ran() { [ $((RANDOM%100)) -lt ${1:-50} ]; }
2015-07-16 00:06:25
User: sesom42
0

Command will succeed n% of the time.

ran 75 will cause command to succeed 75% of the time.

No argument will cause it to succeed 50% of the time.

Know a better way?

If you can do better, submit your command here.

What others think

The way in which this http://www.rolexreplicasale.org.uk/ rolex replica uk is actually fairly awesome, since the view just offers 1 overhead with no pushers, the actual bezel is actually switched possibly left in order to the best to help along with along with http://www.rolexreplicastoreuk.org.uk/ rolex replica uk the different features. This functions remarkably nicely and it is the main complex mystique from the http://www.rolex-replica-uk.co.uk/ rolex replica sale one of the uncommon complicated Rolex wrist watches. Obviously, Rolex might make more difficult http://www.hublotreplicauk.co.uk/ hublot replica when they desired to, however provided the actual effectiveness device that they're, these people achieve this moderately, simply because complex actions consider much more treatment to put together without having concern. Exactly what additionally can make the actual http://www.khaosan-hotels.com/popup/superior.html rolex replica sale distinctive may be the situation dimension. From 42mm broad, the actual Rolex Sky-Dweller is actually amongst just a couple larger Rolex wrist watches, using the Explorer II 42mm as well as, once more, the actual http://www.replicawatch.us.com/ replica watches sale. If you're accustomed to 42mm broad wrist watches, anticipate the actual Rolex Sky-Dweller in order to put on instead large provided the actual broadly spread lugs.

Comment by hoowei 33 weeks and 3 days ago

Your point of view

You must be signed in to comment.