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.

Universal configuration monitoring and system of record for IT.

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:



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!

Top Tags



Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

Commands tagged newline from sorted by
Terminal - Commands tagged newline - 9 results
pbpaste | tr '\r\n' '\n' | tr '\r' '\n' | pbcopy
2012-07-31 10:50:14
User: adambrenecki
Functions: tr

Copying and pasting from Office documents open in Office:mac can dirty your files with Windows CRLF and (inexplicably) Classic Mac OS LF newlines, which can break some tools. This snippet replaces them with good ol' Unix LF newlines.

read -d ""
2011-10-25 18:44:11
User: totti
Functions: read

Handle any bad named file which contains ",',\n,\b,\t,` etc

Store the file name as null character separated list

find . -print0 >name.lst

and retrieve it using

read -r -d ""


find . -print0 >name.lst; cat name.lst| while IFS="" read -r -d "" file; do ls -l "$file"; done
find . ! -name "$(printf '*[\001-\037\177]*')"
perl -ple 'BEGIN { $\ = "\r\n" }'
2011-03-01 09:45:37
Functions: perl
Tags: perl newline

Let -p do it's voodoo and do absolutely nothing but set the output record separator :-)

awk 'BEGIN{RS="\0"}{gsub(/\n/,"<SOMETEXT>");print}' file.txt
2010-12-12 21:43:22
User: __
Functions: awk

awk version of 7210. Slightly longer, but expanding it to catch blank lines is easier:

awk 'BEGIN{RS="\0"}{gsub(/\n+/,"<SOMETEXT>");print}' file.txt
2010-09-11 18:51:41
User: mensa13

In case the line you want to join start with a char different than ", you may use \n.*"\n as regex.

:%s/\([^\"]\)\(\n\)/\1 /g
2010-09-03 11:03:49
User: godzillante


this line ends here

but must be concatenated with this one

"this line ends here"

and should NOT be concatenated with this one

export IFS=$(echo -e "\n")
2009-07-09 15:25:37
User: darkpand
Functions: echo export

When you use a "for" construct, it cycles on every word. If you want to cycle on a line-by-line basis (and, well, you can't use xargs -n1 :D), you can set the IFS variable to .

fold -s -w 90 file.txt
2009-05-11 23:00:25
User: vincentp
Functions: fold

wraps text lines at the specified width (90 here).

-s option is to force to wrap on blank characters

-b count bytes instead of columns