/dev/clipboard: The most Unixy thing on Windows/Cygwin

James Smith


For a long time, I have relied on the Cygwin environment to emulate a Unix-like experience on Windows. Cygwin provides not only some common Unixy command line utilities but also a Linux-like file system hierarchy that includes /dev and /proc. For example, copying a CD-ROM is simply cat /dev/cdrom >file.iso

One of the special files in /dev is /dev/clipboard, which allows you to read and update the Windows clipboard as if it were a local file. Many of my workflows include /dev/clipboard. A concrete example is copying a column in Excel, transforming it in the command line, and pasting it back.

# View the clipboard
cat /dev/clipboard
# Find something on the clipboard
cat /dev/clipboard |grep something
# Transform the clipboard data in-place
cat /dev/clipboard |sed ... |tee /dev/clipboard

And many of my scripts take /dev/clipboard as the input/output, such as launching Google to search the clipboard.

AFAIK, this thing hasn’t been replicated on Linux. Maybe someone could implement it with FUSE.

Welcome to build-your-own.org.

A website for free educational software development materials.


for updates and new books.

Book Cover

Read the book “Build Your Own Redis” online.

Learn network programming and data structures.

By build stuff from scratch.

With straightforward C/C++ code.

Book Cover

Read the book “Build Your Own Database” online.

Learn 3 important database topics:

  • Persistence.
  • Indexing.
  • Concurrency.
Book Cover

New book:
“From Source Code To Machine Code”

Build your own compiler from scatch. Topics covered:

  • Interpreters.
  • Compilers.
  • x64 assembly.