Skip to content

Instantly share code, notes, and snippets.

@tavinus
Last active October 3, 2018 03:27
Show Gist options
  • Select an option

  • Save tavinus/4cf3f0fc18b09b7f324d87064c4d8e49 to your computer and use it in GitHub Desktop.

Select an option

Save tavinus/4cf3f0fc18b09b7f324d87064c4d8e49 to your computer and use it in GitHub Desktop.
List only executable files (and not folders)
#!/bin/bash
# List only executable files
# Will ignore folders
# Gustavo Arnosti Neves
# https://github.com/tavinus
# Usage ./lsexec.sh
# ./lsexec.sh <path>
# One-liners
# wget 'https://gist.githubusercontent.com/tavinus/4cf3f0fc18b09b7f324d87064c4d8e49/raw/lsexec.sh' && chmod +x lsexec.sh
# curl -L -O -J 'https://gist.githubusercontent.com/tavinus/4cf3f0fc18b09b7f324d87064c4d8e49/raw/lsexec.sh' && chmod +x lsexec.sh
# System Install
# sudo cp lsexec.sh /usr/bin/lsexec && sudo chmod +x /usr/bin/lsexec
# lsexec
rp=''
if [[ ! -z "$1" ]]; then
rp="$(realpath -m "$1")"'/'
if [[ ! -d "$rp" ]]; then
printf "%s\n" "Error! \"$rp\" is not a valid folder to read from..." >&2
exit 1
fi
fi
for i in "$rp"* ; do [[ -x "$i" ]] && [[ ! -d "$i" ]] && printf "%s\n" "$i" ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment