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.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
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:
Similarly, if you want to print from 10 to the end of line you can use: sed -n '10,$p' filename
This is especially useful if you are dealing with a large file. Sometimes you just want to extract a sample without opening the entire file.
Credit goes to wbx & robert at the comments section of http://www.commandlinefu.com/commands/view/348/get-line1000-from-text.#comment
The description of how the one-liner works is here at my blog:
http://jugad2.blogspot.com/2008/09/unix-one-liner-to-kill-hanging-firefox.html
From a saved page of google search results, split out all of the links for the results. Useful for creating apache rewrite rules from.
If the file content is :
-
Blah blah blah
ABC
hello blah blah blah
bloh bloh bloh
DEF
Bah bah bah
-
You'll get:
-
ABC
hello blah blah blah
bloh bloh bloh
DEF
If you have a file full of numbers written line by line, you can sum every line to get the total.
With a file like this:
3443535
9878977
67554
987798
232324
you will got:
14610188
Replaces A with B in binary file "orig" and saves the result to "new". You must have the hex representations of A & B. Try od: echo -e "A\c" | od -An -x
Does an in situ search-replace but leaves a datestamped backup. A variation with more precision:
sed -i.`date +%Y%m%d%H%M%S 's/pattern/replace' [filename]
Very quick way to change a word in a file. I use it all the time to change variable names in my PHP scripts (sed -i 's/$oldvar/$newvar/g' index.php)
customizable context searches - if you know sed, this is a basis for more complex context control than grep --context offers
Function to remove a specified path from your PATH environment variable.
rename a pattern matched files by stripping off the extension
This grabs all lines that make an instantation or static call, then filters out the cruft and displays a summary of each class called and the frequency.
Sed stops parsing at the match and so is much more effecient than piping head into tail or similar. Grab a line range using
sed '999995,1000005!d' < my_massive_file