Home > front end >  how to write a bash script to scan my ubuntu server if any ".sql " is present or not?
how to write a bash script to scan my ubuntu server if any ".sql " is present or not?

Time:05-27

I want a bash script for my ubuntu server to scan " .sql , .gzip, .tar, .gz, .bz2 " is present or not .If any of these files are present, I want to send this information like file containing path to a particular mail id. How can I get help ?

CodePudding user response:

Assuming your server has a properly set up sendmail,

find / \
    \( \
      -name "*.sql" -o \
      -name "*.gzip" -o \
      -name "*.tar" -o \
      -name "*.gz" -o \
      -name "*.bz2" \
    \) \
    -print | \
  mail -s "List of files of interest" [email protected]

This may take a long time; if you can isolate a directory under which you want to search, replace find / with find /path/of/interest.

CodePudding user response:

you can scan the system using find command:

#!/bin/bash 
find . -name *.sql
  • Related