Easy search on db dumps
by justanuser, 24-04-2021 - 03:19 PM

Post by
Hello Everyone!!
I wanted to share with you a little script that allows you to automatically search on multiple files automatically.
As you might already know, databases dumps are huge! Sometimes people divide them into multiple files to be able to manipulate them with more ease and this is good! but brings us a problem.

If you have a bash terminal and one dump file you could do something like this:

cat dumpFile.txt | grep usernameOrEmail

But what happens when the dump is divided into 25 files? are you gonna do that for all the files?
Let's automate this!

Create a file with the name you want with the extension .sh (searchAllFiles.sh for example) and paste this inside


for i in *.txt <--
echo searching in $i
cat $i | grep usernameOrEmail <--
Modify the text where arrows are pointing (and delete the arrows too...)
The .txt will most likely stay the same, but be sure to modify it according the file extension of your dump
In the usernameOrEmail you will put what your looking for (so the username or email of the person)

on your terminal simply do the following command to make your script executable

chmod +x searchAllFiles.sh
And then lauch your script inside the folder will all the dump files like this

If the script finds something with your keyword in it, it will display it on screen preceding the file name, if nothing is found you will just see
searching in filename.txt

Good luck
Reply Return to top

Forum Jump:

  Users browsing this thread: 1 Guest(s)