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:
This command will "su" the execution of the command to the postgres user(implies that you are already logger as root), and export the result of the query to a file on the csv format.
You'll need to adequate the fields and database information to one of your choice/need.
Produces a CSV file containing fronts/backs of cards with specified tag ("mytag" above). This command pulls these cards from different card databases, and allows them to be merged into one (by importing the resulting CSV file).
The CSV file is not directly produced; instead of commas, "||" are inserted. In your editor of choice, modify the resulting file to put quotes around the text before || and after ||, then change || to a comma (for every line).
Useful for CSV files. In the command, the file in question is comma delimited but contains double quoted fields containing commas and contains no @ symbols (as confirmed with http://www.commandlinefu.com/commands/view/9998/delimiter-hunting). This command converts the delimiting commas to @s while preserving the commas in the fields using the "uniqueString" to mark the ends of lines.
Similar output to using MySQL with the \G at the end of a Query. Displays one column per line. Other modes include:
Query results will be displayed in a table like form, using whitespace characters to separate the columns and align the output.
-html Query results will be output as simple HTML tables.
-line Query results will be displayed with one value per line, rows separated by a blank line. Designed to be easily parsed by scripts or other programs
-list Query results will be displayed with the separator (|, by default) character between each field value. The default.
From inside the command line this can be also changed using the mode command:
.mode MODE ?TABLE? Set output mode where MODE is one of:
csv Comma-separated values
column Left-aligned columns. (See .width)
html HTML code
insert SQL insert statements for TABLE
line One value per line
list Values delimited by .separator string
tabs Tab-separated values
tcl TCL list elements
Will handle pretty much all types of CSV Files.
The ^M character is typed on the command line using Ctrl-V Ctrl-M and can be replaced with any character that does not appear inside the CSV.
Tips for simpler CSV files:
* If newlines are not placed within a csv cell then you can replace `map(repr, r)` with r
More of the same but with more elaborate perl-fu :-)
This little command (function) shows the CSV header fields (which are field names separated by commas) as an ordered list, clearly showing the fields and their order.