Copy & Paste from Kindle Without Citation

I read an old book in Kindle on Mac that has no copyright anymore. Whenever I copy & paste, also the citation will be pasted. How can I copy & paste without citation?

I found a potential solution using Mac Automator, but the zsh code does not work (citation is still there). What code should I use instead to make it work?

From my limited testing, it appears that the Kindle app for Mac will include the citation as the last line of whatever you copy from it, preceded by a blank line.

So the question becomes: “How do we delete the last line from something?”

The answer (well, an answer) is

sed '$d'

which will delete the last line of a file, or of the input which is given to it.

That will leave you with a blank line at the end of your pasted text. If you want to delete that line too, you can use sed '$d' again, like so:

sed '$d' | sed '$d'

Assuming that will receive the pasteboard from stdin and send the result to stdout that should work.

I haven’t used Automator much, but it would be easy to do this in Keyboard Maestro.

This worked, thank you sooo much @Tjluoma :slightly_smiling_face:

I would be very thankful if you can send here the final script you used to make it work. I can figure out the rest in either automator or maestro.

Hi @sharfaroz ! Welcome to the forums!

If @Timm218 doesn’t reply in a few days, feel free to send me a DM here and I’ll see if I can help.

(I think you can send me a message by clicking on my name/icon or here.)