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/
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.
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.
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:
If this command prints 'x' then your shell is vulnerable. Null output confirms that you are protected. Further reading: http://allanmcrae.com/2014/09/shellshock-and-arch-linux/
List all dependencies manifests so you can install them.
In a scenario where you want to deploy a number of web applications and run their dependency managers, how could you run all of them in a systematic order.
One of the complexity is to ensure you get only your own top level dependencies. That way, you don recursively call development dependencies of your own dependencies.
Otherwise you might end up discovering dependency management manifests that are already been pulled by your own projects.
# Using this command
This command helps me find them and I can then run what?s required to pull them from their respective sources.
This command assumes the following:
1. Your code checkouts are in a flat repository layout (i.e. not nested).
2. Finds manifests for:
- NPM (nodejs),
- Composer (php),
- requirements.txt (Python), and
- git submodules
replace all "?" characters in filename to underscore
rename all dirs with "?" char in name, leave spaces and () in place
Easiest way to get the external IP address.
Allows you to have a list of the domains on the server.
Google Cloud SDK comes with a package manager `gcloud components` but it needs a bit of `sed` to work. Modify the "^| Not" bit to change the package selection. (The gcloud --format option is currently broken)
This command will use grep to read the shortcut (which in the above examle is file.url), and filter out all but the only important line, which contains the website URL, and some extra characters that will need to be removes (for example, URL=http://example.com). The cut command is then used to get rid of the URL= at the beginning. The output is then piped into Firefox, which should interpret the it as a web URL to be opened. Of course, you can replace Firefox with any other broswer. Tested in bash and sh.
Its possible to user a simple regex to extract de username from the finger command.
The final echo its optional, just for remove the initial space
Send a text message to an Kodi (XBMC) device. Uses curl to post a JSON request to the Kodi JSON-RPC API.
Improved google text-to-speech function. Allows to specify language, plays sound in terminal. Automatically removes downloaded file after successfully processing.
say LANGUAGE TEXT
say en "This is a test."
say pl "To jest test"
# AllInOne: Update what packages are available, upgrade to new versions, remove unneeded packages
# (some are no longer needed, replaced by the ones from ap upgrade), check for dependencies
# and clean local cached packages (saved on disk but not installed?,some are needed? [this only cleans unneeded unlike ap clean]).
# aliases (copy into ~/.bashrc file):
a r='ap autoremove -y'
a up='ap update'
a u='up && ap upgrade -y --show-progress && r && ap check && ap autoclean'
# && means "and run if the previous succeeded", you can change it to ; to "run even if previous failed".
I'm not sure if ap check should be before or after ap upgrade -y, you can also change the alias names.
# To expand aliases in bash use ctrl alt e or see this ow.ly/zBKHs
# For more useful aliases go to ow.ly/zBMOx
bash brace expansion, sequence expression
A simple bash function to the find command. I use this much more than find itself.
World Cup Live Score of the ongoing match.
Alternative to have the live score with the match statistics:
watch -n10 --no-title "w3m http://www.livescore.com/ |awk '/live [0-9H]+[^ ]/,/red cards/'"
Useful if you don't have at hand the ability to automatically create a booklet, but still want to.
F is the number of pages to print. It *must* be a multiple of 4; append extra blank pages if needed.
In evince, these are the steps to print it, adapted from https://help.gnome.org/users/evince/stable/duplex-npage.html.en :
1) Click File ▸ Print.
2) Choose the General tab.
Under Range, choose Pages.
Type the numbers of the pages in this order (this is what this one-liner does for you):
n, 1, 2, n-1, n-2, 3, 4, n-3, n-4, 5, 6, n-5, n-6, 7, 8, n-7, n-8, 9, 10, n-9, n-10, 11, 12, n-11...
...until you have typed n-number of pages.
3) Choose the Page Setup tab.
- Assuming a duplex printer:
Under Layout, in the Two-side menu, select Short Edge (Flip).
- If you can only print on one side, you have to print twice, one for the odd pages and one for the even pages.
In the Pages per side option, select 2.
In the Page ordering menu, select Left to right.
4) Click Print.
What's wrong with this?
Regular expression search pattern to remove the Datetime and Name when you paste from skype chat into your text editor
From this Gist:
Extracts domain and subdomain from given URl. See examples.