#!/bin/sh # File where the input will be appended board_file="/var/nex/board" # Temporary buffer to hold incoming data temp_buffer="" # Read input line-by-line while IFS= read -r line; do # Break if the line is just a dot [ "$line" = "." ] && { echo "Thank you hero! We are done here. Text should be at the board now." 1>&2; break; } # Append the line to the buffer temp_buffer="$temp_buffer$line"$'\n' done # Append the buffered input to the board file if there's any input if [ -n "$temp_buffer" ]; then echo "----------------------------------------------------------------------" >> "$board_file" echo "NEXT ONE $(date)" >> "$board_file" echo -e "$temp_buffer" >> "$board_file" fi # Exit the script exit 0