#!/bin/bash

# Directory to monitor
directory="/path/to/directory"

# Check if the directory exists
if [ -d "$directory" ]; then
# Find the newest file in the directory
newest_file=$(ls -t "$directory" | head -n1)

# Check if at least one file is present in the directory
if [ -n "$newest_file" ]; then
echo "Monitoring $newest_file..."

# Run tail -f on the newest file
tail -f "$directory/$newest_file"
else
echo "No files found in the directory."
fi
else
echo "The directory does not exist."
fi

----------------------------------------------------------------
put an alias to .bash_rc to have a command available in your environment

alias livelog='/path/to/your/script.sh'

computer2know :: thank you for your visit :: have a nice day :: © 2024