history | tail -n 10 | awk '{$1=""; print substr($0,2)}'

get_history.sh

#!/bin/bash
 
# Number of last commands to retrieve
NUM_COMMANDS=${1:-10}  # Default to 10 if no argument is provided
 
# Get last commands without numbers
history | tail -n "$NUM_COMMANDS" | awk '{$1=""; print substr($0,2)}'

Usage:

  1. Save the script as get_history.sh.
  2. Make it executable:
    chmod +x get_history.sh
  3. Run it:
    ./get_history.sh 5  # Replace 5 with any number of last commands you want