Take the tour ×  I have 5 filenames created inside a folder for
one operation.The filenames are in the following format.   I
want to read the status from the latest created file in that
path.  The way I form the filename in shell script is:  $
filename=ES_*_uniqueid.log $ echo grep "##status##XRB##"
$HOME/log/$filename | sort -u` "  When I grep it reads the
status from all 5 files and echoes it. I want the string to be
grep only from the latest file that got created.  Could some one
provide a solution?  share|improve this question Can you please
show the actual names of a couple of the files? Need to see the
timestamp format. –  slm Aug 8 at 7:27 You was needed to put
only one file to grep input and that file should be the last
modified; slm did it :) –  rook Aug 8 at 7:52 add comment  2
Answers  So long as the files were written in chronological
order the names of the files doesn't really matter. Just use
tail -1 to get the last file in a listing of the files and that
should always be the latest file:  $ fil