forked from MiXXiM/miscellaneous
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlspath
31 lines (25 loc) · 791 Bytes
/
lspath
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
#!/bin/sh
#------------------------------------------------------------------------------
# Project Name - ShellProjects/source/lspath
# Started On - Sun 18 Jun 12:57:24 BST 2023
# Last Change - Mon 19 Jun 23:34:57 BST 2023
# Author E-Mail - [email protected]
# Author GitHub - https://github.com/terminalforlife
#------------------------------------------------------------------------------
# Portable script to list executable files in `$PATH`.
#------------------------------------------------------------------------------
Dirs() {
OldIFS=$IFS
IFS=':'
set -- $1
IFS=$OldIFS
for Dir in "$@"; do
Dir=${Dir%/}
for File in "$Dir"/*; do
if [ -f "$File" ] && [ -x "$File" ]; then
printf '%s\n' "$File"
fi
done
done
}
Dirs "$PATH"