How to print the contents of an OSX text-click file from a terminal?

On OSX (I'm on 10.7.x, Lion) you can grab some text from most applications and drag it to the desktop to get the file "snippet.textClipping". The file is not only raw text, although - the text is hidden somewhere (in the resource?) I tried to shout from DeRez, but could not bend it of my own free will. What I'm looking for is the ability to get what could be considered the result

cat mysnippet.textClipping

NOTE. These clippings were made in an older version of OSX. Maybe Leopard. Maybe older, some time has passed. :)

Thanks!

PS I have a folder with 1600+ of them, so I'm looking for a script, and not just manually copy / paste them into a text file.

PPS Yes, if I just select - everything and then drag it into an open empty text document, it will do what you expect. But I still want to do this through a script, so I can first specify the clipping name and an empty string before each, etc.

+6
source share
1 answer

Here's something ugly that might work:

 DeRez -only TEXT foo.textClipping | perl -ne 'm|/\* (.*) \*/| && print $1; END {print "\n"}' 

Basically, it extracts text from C-style comments in DeRez output and prints it all on one line. I got the idea from another stack overflow question (which I cannot find now).

+4
source

Source: https://habr.com/ru/post/919900/


All Articles