Gregg's MOTD

Tips & Tricks that I've Encountered Over the Years...

How To Find All of the Shell Scripts In a Directory

May 21, 2023 — Gregg Szumowski

This is a quick and dirty way which will list all of the files that are shell scripts:

for i in *
do
type=$(file ${i}|awk -F, '{print $2}')
if [[ "${type}" = " ASCII text executable" ]]; then
echo "${i} is a shell script"
fi
done

Tags: cli, motd, awk