[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Speeding up a find and subsequent grep
From: |
Jeffrey Walton |
Subject: |
Speeding up a find and subsequent grep |
Date: |
Sat, 19 Dec 2020 07:04:14 -0500 |
Hi Everyone,
I'm working on CentOS 7, x86_64, fully patched. The server has a
manual wiki installation. Ownership and permissions need to be set
after an update. I've got a script that does it. The slowest part of
the script is this:
# Make Python, PHP and friends executable
IFS= find "$WIKI_DIR" -type f -print | while read -r file
do
if file -b "${file}" | grep -q -E 'executable|script';
then
chmod u=rwx,g=rx,o= "${file}"
else
chmod u=rw,g=r,o= "${file}"
fi
done
Some of the files have whitespace in their names so I need something
like 'find -print | while read'.
When I added the 'file -b' piped to 'grep -E' the script slowed down
considerably.
Is there any way to speed up that portion of the script?
Thanks in advance.
Jeff
- Speeding up a find and subsequent grep,
Jeffrey Walton <=