#!/bin/bash # This script is used for getting last 100 lines of a screen session SCREEN_NAME="$1" LIMIT="${2:-100}" SCRIPT=$(basename "${0}") if [ -z "$SCREEN_NAME" ]; then echo "Usage: ${SCRIPT} " exit 1 fi screen -S "$SCREEN_NAME" -X hardcopy /tmp/screen-hardcopy tail -n "${LIMIT}" /tmp/screen-hardcopy rm /tmp/screen-hardcopy