linux - How do I find the latest date folder in a directory and then construct the command in a shell script? -


I have a directory in which I will have some folders with the date format (YYYYMMDD) shown below -

  David @ Machine X: / Database / Batch / Snapshot $ ls -lt drwxr-xr-x 2 ap kit 86016 25 Oct 05:19 20141023 DroxsR-XR-X2 App Kit 73728 18 October 00 : 21 20141016 Dracoxer -xr-x2 app kyte 73728 9 October 22:23 20141009 drwxr-xr-x 2 ap kyte 81920 4 October 03:11 20141002 Now I need to remove the latest date folder Create the command in the   / Database / Batch / Snapshot  directory and then in my shell script - 

  ./ file_checker --directory / database / batch / snapshot / 20141023 / --regx ". * Data." & Gt; Shardfile_20141023.log  

Below is my shell script -

  #! / Bin / bash ./file_checker --directory / database / batch / snapshot / 20141023 / --regax ". * Data." & Gt; Shardfile_20141023.log # Now I need the gard shardfile_20141023.log after executing the above command  

How do I get the latest date folder and by creating the above command in a shell script Can i

Look, this is a method, just repeat those folders who have 8 digits:

  LS-T1 | Grep -P -e "\ d {8}" | Head-1  

or

  LS-T1 | Grep -E -e "[0- 9] {8}" | Head-1  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -