I\'m trying to create a macro for Keyboard Maestro for OS X doing the following:
You can do that in bash in a single statement like so:
echo -n "newest file: $(ls -t |head -n1)"
You can also remove that newline without echo:
ls -t |head -n1 |tr -d '\n'
Make sure ls doesn't output colors to non-tty streams (i.e. specify color by ls --color=never or ls --color=auto or not at all).
The ls solution will output files of any kind sorted by modification time. If you want only regular files or if you don't want directories then you can use find and xargs:
echo -n "newest file: $(find . -maxdepth 1 -type f -print0 |xargs -0 ls -t)"