Create the RAM disk:
diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://1165430`
(the magic number 1165430 is explained here as the number of 512 byte sectors. The string "ramdisk" is just the name of the disk, which will appear under /Volumes after creation)
Write some stuff to the RAM disk:
echo "hello RAM disk" > /Volumes/ramdisk/hello.txt
Eject the RAM disk:
diskutil eject /Volumes/ramdisk
Found this guide for creating a RAM disk on Linux, but have not tried it yet.