May 05, '03 09:48:00AM • Contributed by: Kynn
You can strip out unwanted text or otherwise modify your clipboard by using the pbpaste and pbcopy shell commands from the Terminal. (These were previously discussed in this tip, but this is a new technique.)
Here's an example. Let's say I just copied something from the message history in Proteus, which I have set to display timestamps. I want to remove all the timestamps, which all end in "US/Pacific" -- my time zone. To do this, I'll pipe the clipboard contents through grep, and store the output back on the clipboard.
pbpaste | grep -v 'US/Pacific$' | pbcopy
My paste buffer (clipboard) has now been cleansed of all lines ending in the time zone. I can paste it into other applications without the time zones showing up. There are a number of cool applications for this, including the use of the Unix tr command. Want to rot13 your clipboard? Try this:
pbpaste | tr 'a-zA-Z' 'n-za-mN-ZA-M' | pbcopyA simple sed script such as this one from sed.sourceforge (more here) will let you convert foreign text to HTML entities if you're pasting into your blog. Removing Microsoft "smart quotes" is also pretty easy using tr, sed, or something like the deMoroniser Perl script. And, yes, you can also pipe it through jive or Swedish chef filters.