~dricottone/my-utils

my-utils/core/shebangs -rwxr-xr-x 783 bytes
a5400e39Dominic Ricottone Starting point for cryptographic utilities 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh

name="shebangs"
version="1.0"
usage_message="Usage: shebangs [PATH]"
help_message=$(/usr/bin/cat <<-EOF
	Print the shebang line of each executable script
	Usage: shebangs [PATH]
	Options:
	 -h, --help     print this message and exit
	 -v, --version  print version number and exit
EOF
)

. /usr/local/lib/myminiparse.sh

# loop through arguments
dir=
for arg; do
  case "$arg" in
  -q|--quiet)
    #ignore these
    ;;

  *)
    if [ -z "$dir" ]; then
      dir="$arg"
    fi
    ;;
  esac
done

if [ -z "$dir" ]; then
  dir="."
fi

/usr/bin/find "$dir" -maxdepth 1 -type f -printf "%f\0" \
  | /usr/bin/sort -z \
  | while IFS= read -r -d '' fn; do
  /usr/bin/printf '%s:' "$fn"
  /usr/bin/head --lines=1 "$fn"
done | grep --regexp=':#!' | column --separator ':' --table