Read text file with with name between X and Y bash -


I was making a Bash script to make it easier for other system administrators to read a fixed folder with log files I am So far the script has two variables, $ STARTDATE & amp; $ ENDDATE. Every day is a log file, in this case YYYY-mm-dd.log is called. I want to output the script to the contents of all log files with a name that is equal to or equal to two variables. For example: if I enter $ STARTDATE of 2015-01-18, and a $ ENDDATE of 2015-01-20, I want to output the contents of the script:

  • 2015 -01-18.log
  • 2015-01-
  • 2015-01-20.log

what An easy way to do this?

Thank you!

If you are using bash and can guarantee that the log file format is consistent, then You should be able to use something like this.

  startdate = $ 1 enddate = $ 2 for logfile / path / to / logfiles / *; Do lf = $ (original name "$ logfile" .log) if [["$ lf" & gt; "$ Startgate" & amp; Amp; "$ Lf" & lt; "$ Enddate"]; Then the "### $ logfile" cat was used for "$ logfile"  

Note that I have lowercase startdate and end date The general practice is that the ALL_UPPER variable is reserved for Shell / etc.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -