Share text instantly with this open source command | Opensource.com

Share text instantly with this open source command

Use pastebinit to share snippets of code, data, or text right from the command line.

share word on code background
Image by : 
Opensource.com
x

Subscribe now

Get the highlights in your inbox every week.

Pastebin.com and similar websites make it quick and easy to share snippets of code, data, or text. Pastebin sites are often used when filing bug reports because projects often request that lengthy files or log outputs are put into a separate site. Sharing (non-sensitive) data over a pastebin site is helpful for doing this type of troubleshooting or collaboration while keeping bug reports easy to read.

But did you know you can publish a file from your computer or a Raspberry Pi to a pastebin site with a single command, pastebinit? It's open source licensed under GPLv2.0, and you can access its source code on GitHub.

Here's how to use it.

Install pastebinit

On a Raspberry Pi:

$ sudo apt install pastebinit

On Fedora or similar:

$ sudo dnf install pastebinit

MacOS users can install it using the Homebrew package manager with brew install pastebinit.

Share files with pastebinit

Usage is flexible and straightforward. Run pastebinit with the file you want to share, and it returns the URL where the file is shared:

The default pastebin provider in Raspbian is paste.debian.net, and Ubuntu's default is paste.ubuntu.com.

There are two other ways to input a file. One is by piping to pastebinit:

$ less <filename> | pastebinit

Or you can redirect a file to the command:

$ pastebinit < <filename>

All three options give the same results: the file is now visible online. Be sure you only share sanitized information because it will be publicly available.

Conclusion

Since sharing logs from a system is common when troubleshooting and reporting bugs, it's helpful to use pastebinit as a quick way to get those files to a publicly available location. Be sure to only share files without usernames, passwords, or other personally identifying information you do not want to give to… everyone. If you feel confident that you know what you're sharing and why, pastebinit can save you a lot of time.

Snake charmer cartoon with a yellow snake and a blue snake

A quick primer on the handy log library that can help you master this important programming concept.

Topics

About the author

Ben Nuttall - Ben is a software engineer for BBC News Labs, and formerly Raspberry Pi's Community Manager. He's into Linux, Python and all things open source! Follow Ben on Twitter @ben_nuttall.