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:
Code:
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
Code:
#!/bin/bash
for i in *.txt do echo searching in $i cat $i | grep usernameOrEmail done
BEFORE USING Modify the text in bright blue. 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)
HOW TO USE Simple! on your terminal simply do the following command to make your script executable
Code:
chmod +x searchAllFiles.sh
And then lauch your script inside the folder will all the dump files like this
Code:
./searchAllFiles.sh
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