I have several .js files (kinda long files), and I would like to know if there is a way to scan those files and find out if there is any jquery syntax present.
Regards,
Terminal/command line:
for file in *.js;
do
grep "\$(\|jQuery(" $file;
done;
This will search all JS files in the present directory and return any actual occurrence of jQuery's telltale "$("
OR non-aliased instance of jQuery(
.
You can use a regex for more specific selectors if you want.
This will return the filename instead of the code (make sure there are no spaces in the filename).
for file in *.js
do
if grep -q "\$(\|jQuery(" $file;
then echo "$file likely uses jQuery";
fi
done
Single line:
for file in *.js; do if grep -q "\$(\|jQuery(" $file; then echo "$file likely uses jQuery"; fi; done;
Note that this doesn't account for any other libraries or languages that may use $
and could have false positives if your JS includes something like "Bob loves money $(money!)," which clearly isn't jQuery at all. But, at least it will still flag all the files for you to check...