#!/bin/bash

# Check if directory is provided as argument, else use current directory
dir="${1:-.}"

# Check if the provided directory exists
if [ ! -d "$dir" ]; then
  echo "Error: '$dir' is not a valid directory."
  exit 1
fi

# Loop over all files in the directory
for file in "$dir"/*; do
  if [ -f "$file" ]; then
    echo "==> $file <=="
    cat "$file"
    echo -e "\n\n"  # Add some spacing between outputs
  fi
done

Updated: