Adding in comments to ask specific questions as I go:
Single or double quote marks when settings strings?
echo "Starting..."
Do I need to terminate the line with a ;?
TARGET_DIR="~/Downloads"
I can't get the $TARGET_DIR to expand, tried quotes, preens with $etc,
is there a canonical beginners guide to these types of issues that presents
them in the proper way, not the force it to work with back tics and multiple lines?
LAST_DOWNLOADED_FILE=$(ls -t $TARGET_DIR | head -n1)
echo "Your newest file in $TARGET_DIR is: $LAST_DOWNLOADED_FILE"
When run on Mac, I get:
ls: ~/Downloads: No such file or directory
Your newest file in ~/Downloads is:
Trying as a one liner:
me@compy $FOO="~/Downloads"; echo $(FOO); ls -t $FOO | head -n1
-bash: FOO: command not found
man commandprovides useful information