Created
May 17, 2023 11:18
-
-
Save u1i/66ba72ddaee5ff16b529653b4738dd4c to your computer and use it in GitHub Desktop.
Chrome Watcher - what files does it read and write
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Array to store the filenames from the previous loop | |
previous_files=() | |
# Infinite loop | |
while : | |
do | |
# Run the lsof command and filter for Google Chrome process | |
files=$(lsof -c "Google Chrome" | awk '{print $9}' | sed '1d') | |
# Loop over the filenames | |
while IFS= read -r filename | |
do | |
# Check if the filename is not in the previous_files array and is a file in the macOS filesystem | |
if [[ ! -z "$filename" ]] && [[ ! "$filename" =~ ":" ]] && [[ -e "$filename" ]] && ! [[ " ${previous_files[@]} " =~ " ${filename} " ]]; then | |
# Print the filename | |
echo "$filename" | |
# Add the filename to the previous_files array | |
previous_files+=("$filename") | |
fi | |
done <<< "$files" | |
# Wait for a few seconds before the next loop | |
sleep 5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment