Skip to content

Instantly share code, notes, and snippets.

@Blumed
Last active March 26, 2017 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Blumed/d928da541eed34fc0eb88675808219f5 to your computer and use it in GitHub Desktop.
Save Blumed/d928da541eed34fc0eb88675808219f5 to your computer and use it in GitHub Desktop.
A bash function that takes file extensions as arguments. You may pass as many as you want and output each file name matching your extension into a file so you can copy and past from it quickly or share your custom file list
filelist() {
if [ $# -gt 0 ]; then
shopt -s nullglob
for ext in "$@"; do
printf '%s\n' *.$ext
done | pbcopy
echo "copied listing for $@ files to clipboard"
else
shopt -s nullglob
for ext in *.*; do
echo "$ext"
done | pbcopy
echo "copied listing for all files to clipboard"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment