I'm attempting to write a shell script for BusyBox (v1.27.1) wherein the script, in part, needs to extract the last item from a list/multiline variable, which contains a list of absolute file paths. I've been working on this most of the day, and still no joy. What am I doing wrong?
TARGET_DIRECTORY="/usr/bin" # can be any valid location
ALL_LOG_FILES=$(find $TARGET_DIRECTORY -maxdepth 1 -regex '.*\.log')
LAST_LINE=$($(`echo $ALL_LOG_FILES`) | tail -1) # broken here
echo "last line=$LAST_LINE"