How to search a file with a given String and currentTimestamp and if not found trigger a mail?
For Ex-:I have to search a file whose filename would be like filename_05172015 and trigger a mail if not found in a given directory? There will be only one file with such filename but would had extra hrs and minutes also appended to it.

  • do you want the extra time digits to be treated as found or as not found? – Skaperen May 17 '15 at 10:14
  • Is that one file or a list of files with the specified naming convention? – ILMostro_7 May 17 '15 at 11:34

Assuming you are using bash (or zsh) and your mail agent is sendmail then:

[[ -f "filename_$(date '+%m%d%Y')" ]] || echo "File is missing!" | sendmail myname@gmail.com

Between [[ and ]] we test if file exists, and if not then print some message and send it to myname.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.