answering #1
Code:
ls -ltr | tail -1
will give you all info on the most recent file in the current folder
Code:
ls -ltr | tail -1 | awk '{print $9}'
will give you just the filename
Code:
MYFILE=`ls -ltr | tail -1 | awk '{print $9}'`
will put that filename into $MYFILE
for #2
normally not best to cd then rm, better to
Code:
rm \dir\folder\*
or similar.
Seen too many examples where the cd failed, and then all files were deleted or some other command executed.
|