Part 2: The Script

Here is the link to send me $4. But you may try out the script first. Thank you for your support.

Instructions:

Step 1: Download the script

Download the script processfb.sh and save it on your local computer to C:\facebook\processfb.sh, or on Mac or Linux as /facebook/processfb.sh , or actually wherever you like. But creating a folder called C:\facebook is a good idea for this project.

(This Mac/Linux version can actually be made to work on Microsoft Windows, however if you really prefer a more native app you can get the Windows Powershell version here instead.)

Step 2: Download the friends list

As mentioned on the previous page, log into facebook, click on your own facebook page, and then Friends. The list appears. With your mouse, select the entire list of friends, but clicking and dragging over that area of the page. Then right-click Copy. In a text editor such as Notepad or any other basic text editor, Paste the text. Save it as a plain text file in UTF-8 format. Name the file “friends.2024-11-15.txt”, for example, or put whatever today’s date is. Save the file into the directory we are using for this which is C:\facebook or /facebook.

Step 3: Launch a Terminal Window

We have to review Windows, Mac, and Linux separately here.

Mac and Linux:

Open a Terminal window.
At the prompt, switch to the directory with the script:
cd /facebook

Windows:

Windows doesn’t have a linux terminal. You will need either:

Cygwin: https://cygwin.com/install.html
then,
cd C:/facebook

or

(not recommended yet, it has bugs) Linux Bash for Windows: http://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/
then,
cd /mnt/c/facebook

Turn on Quick-Editing features.
Cygwin: right-click on the top menu, Options->Mouse, “Copy on Select”, “Right-click Paste”
Bash: right-click on the top menu, Properties, select Quick-Edit Mode

Step 4: Run the script

Run the script as follows:
./processfb.sh friends.2024-11-15.txt

Replacing the filename with whatever your filename from Step 2 was. It will create the output file like “friends.2024-11-15.sorted.txt”, with the word “sorted” added.

If you get any permissions errors, make sure the script is executable:
chmod 755 processfb.sh

Step 5: List Cleanup

Open the newly created file, from the previous step, in any basic text editor. Review it. It’s almost the cleaned-up list of friends, in alphabetical order, but it still contains some extra data such as names of Universities, Towns, Professional Titles. Unfortunately, this is the most laborious step, but it should only take a few minutes hopefully. ANY of the following choices will work, read through them.

Choice 1:
If the script is still running, and it’s prompting you to enter removal patterns, paste them into the script now. That is, paste in lines of text that shouldn’t be in the final output.

Choice 2:
The script has finished, but you can simply re-launch it.
./processfb.sh friends.2024-11-15.txt
Enter the removal patterns, when requested. Re-run the script as often as necessary to add more removal patterns.

Choice 3:
In the file includefb.sh, you will see this section, or if you don’t see it you can add it:

personalpatterns=(
“This is an example. You can replace the words here.”
“And so is this. Paste in text you would like to delete from the output.”
“Each entry should match an entire line of text. no more or less.”
)

You need to edit this section, with the items you want removed from your friend’s list. So after you do this, includefb.sh will look like this, as an example.

personalpatterns=(
“Harvard University”
“Joe’s Paint Shop”
“Gerbils”
)

Whatever text you observe in the friend’s list that you want removed, should be added to this personalpatterns list. Save the file. It is strongly recommended to save the file in UTF-8 text format, which is a choice when saving.

Run the script again now:
./processfb.sh friends.2024-11-15.txt

Check the sorted output file again
friends.2024-11-15.sorted.txt

Still some extra data? Add it to personalpatterns. Rinse and repeat. Run processfb.sh again.

It’s important to keep in mind the concepts from Part 1. We are just trying to create a plain text list of friends. No more and no less. If something extra is appearing, put it into personalpatterns, so it will be removed when the script runs.

Step 6: Friend comparison

After a few months, you notice that your friend count is different. How to figure out who unfriended you? Go through steps 1-5 again, but with the new date. Today’s date. In other words, copy and paste your friends into a new file friends.2025-05-15.txt , run processfb.sh friends.2025-05-15.txt, and it generates the new output file friends.2025-05-15.sorted.txt

Compare the two sorted files from the terminal window. Run the “diff” command. Example:
diff friends.2024-11-15.sorted.txt friends.2025-05-15.sorted.txt

It outputs the differences, along with some computer lingo gobbledygook. You can ignore the < symbols and the 4d5 numbers. Just look at which friend names it mentions. Those are the “differences”. Who has left? Who was added?

That’s it.

Try it out. In the event you have questions, first consult the advanced documentation.

I look forward to your questions via the Contact Form