Sep 06
Some history and a cool command. Was originally used to print the X cut_buffer0 to lpr. Most of what it does is better done with a pipe,  but every once in while it’s the exact thing you need. 
Works under Cygwin X11.
#!/bin/sh
# return selected text. Mark Martin. cetia. france.
# xprop returned format is (eg) CUT_BUFFER0 = “echo \”cetia\\\”\n”
# get the \” and \\ and \n undone. sadly sed wont take long lines.
# sed wont read input not ending in newline, so need to chop off final newline
# use bell as newline marker.
# path added for xprop Frank Summers 1-31-91

# bell=^G
# bell=`echo “\07″`

# xprop -root -notype CUT_BUFFER0 |
# sed ‘1s/[^=]*= “//
# s/\\n/’”$bell”‘/g
# s/\\”/”/g
# s/\\\\/\\/g
# $s/”$//’ |
# tr -d ‘\012′ |
# tr $bell ‘\012′|
# lp

# Wed Mar 22 21:42:45 2000
# very old magic.
# Above is the original
# I got this from from an engineer at the Motorola Computer Group.
# i have done a minor rework so it is a bit cleaner in perl.

# Please note this is one long pipeline with comments in between
# Tony Hansmann (t o n y replacewith-at-sign open source consulting com)


xprop -root -notype CUT_BUFFER0|
perl -pe ’s!^CUT_\w+\s=\s\”!!x; # remove CUT_BUFFER0 = ” part
s!\\n!\n!gx; # make newlines appear as such
s!\\”!\”!gx; # make double-quotes appear as such
s!\\\\!\\!gx; # make back-slashs appear as such
s!\\t!\t!gx; # make tabs appear as such
s!\”$!!x;’

written by admin