I've been setting up a script to work with haste-server. This takes piped or file input (tail /var/log/messages | haste and haste < /path/to/file.txt) and submits it to the server which then outputs a in my terminal. See below:
#!/bin/bash
url="http://hastebin.com"
key="$(curl --silent --data-binary @/dev/fd/0 $url/documents | cut -d "\"" -f 4)"
echo "$url/$key"
It works just fine, however it adds a trailing new line to the input. How can I read @/dev/fd/0 to remove the \n new line?
Edit: Here is my completed script for submitting a haste that trims the newline:
#!/usr/bin/env bash
url="http://hastebin.com"
data=$(< /dev/fd/0)
key="$(printf "%s" "$data" | curl -X POST -s --data-binary @- "$url/documents" | cut -d "\\"" -f 4)"
echo "$url/$key"