commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
Replace all instances of "A" with "B" in file "source" saved as file "destination".
!! IF A/B is multi-byte, then separate bytes with spaces like so: "s/20\ 0A/00/g".
I used this fragment with Imagemagick convert so that I can place long text strings in pictures. The "\n" gets converted to a true newline in the image.
So this fragment uses fold command to wrap the line and then sed to convert newlines (and any trailing spaces on the line) to the text "\n"
I look at xkcd in my news reader, but it displays the image's title attribute only for a few seconds which makes reading the longer ones more challenging. So I use this to display it in my console.
Like 7171, but fixed typo, uses fewer variables, and even more cryptic!
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