Search posterous

Search all posts and users. Type a name, type a favorite song title, whatever! See what comes up.
  

More posterous blogs











More recommended blogs »

Here are posterous posts filed under sed...

divia says...

Click here to download:
First_Letters.workflow.zip (42 KB)

Lately I've been somewhat into memorizing some of my favorite quotations from books. The most effective method I've found for doing so has been converting each word of whatever text I'm trying to memorize to just the first letter, and trying to reconstruct the passage from that. Here's the theory behind why this is helpful:

This is the crucial concept of any type of memorization. The act of reading something you want to memorize fires different connections than the act of recalling. This means that simply reading a particular piece of text over and over again is going to be the long road to memorization. You need to let your brain practice recalling the data so it can strengthen the same pathways that will fire when you need to remember the information later on. You can’t practice recalling until the information is at least partially contained in your short term memory.
-How to Memorize Verbatim Text

So, say I want to memorize this passage from Pawn in Frankincense by Dorothy Dunnett:

The woman sitting there, straight and still on the bright velvet cushions, was not young; nor was she less than beautiful. The black hair, loose and shining, and deep, fell back over her shoulder and forward down to her waist; her chin was high above the pure line of her neck, which you could have held in one hand. Her eyebrows were black, and arched in pride, or surprise, or over some deep, long-held thought; and below the black, silky lashes, the wide eyes were packed full of straw.

Here's what it gets converted to:

T w s t, s a s o t b v c, w n y; n w s l t b. T b h, l a s, a d, f b o h s a f d t h w; h c w h a t p l o h n, w y c h h i o h. H e w b, a a i p, o s, o o s d, l-h t; a b t b, s l, t w e w p f o s.

The website that describes this method provides a helpful JavaScript tool for performing this conversion, but before too long I was finding copying text into the box on the website a little unwieldy. So, I grabbed the relevant regular expression from the JavaScript code (str.replace(/(\w)\w*/g,"$1")) and turned it into an OS X Service, a transformation that, luckily for me, Snow Leopard has made very easy. All the service does is grab some text, run a simple sed replace command (sed 's/\([a-zA-Z0-9]\)[a-zA-Z0-9]*/\1/g'), and output it.

In case this tool I've created could be at all useful to anyone else, I figured I might as well upload it.  To install it, just put it in either /Library/Services or ~/Library/Services.

Filed under: sed

wk says...

Sum number in input.txt

Command:
-----------------------------------------------------------------------------------
$ cat /dos/implement/euler/c13/input.txt | tr "\n" "+" | sed 's/+$/\n/' | bc

Result:
-----------------------------------------------------------------------------------
5537376230390876637302048746832985971773659831892672

Filed under: sed

wk says...

Replace public with private and save output to test2.txt

Command:
===========================================
$ sed 's/public/private/' test1.txt > test2.txt

Filed under: sed

repedo says...

In diesem Video des Soziokulturellen Zentrums Frauenkultur e.V. sprechen Frauen, unter anderem auch Monika Lazar - Abgeordnete der Grünen im deutschen Bundestag und Spitzenkandidatin für Sachsen zur Bundestagswahl - darüber, wie sie die Ereignisse vor ziemlich genau zwanzig Jahren, die wir heute als friedliche Revolution von 1989 bezeichnen, erlebt haben.
Passend zur Diskussion um die Frage Wählen oder Nichtwählen mit Blick auf die Umwälzungen und den Niedergang der SED-Diktatur im Oktober 1989 in der DDR.

Filed under: sed

lambdaphant says...

$ svn st | grep \? | sed "s/\?//" | xargs svn add $1

Filed under: sed

lambdaphant says...

I've found sed really useful lately, but have realized I only use
search and replace. These are some resources that I am going to go
over to better educate myself on awesome sed tricks.
 
http://www.grymoire.com/Unix/Sed.html
http://sed.sourceforge.net/sed1line.txt
http://www.catonmat.net/blog/sed-one-liners-explained-part-one/

Filed under: sed