Skip to content

Instantly share code, notes, and snippets.

@jtpaasch
Last active December 20, 2015 11:09
Show Gist options
  • Save jtpaasch/6121104 to your computer and use it in GitHub Desktop.
Save jtpaasch/6121104 to your computer and use it in GitHub Desktop.
Get all file names (just the basenames) in a directory.
#!/bin/bash
# Get all files in the folder.
FOLDER=/path/to/my/folder/*
# We'll build the list of file names here:
FILES=()
# Add just the basename of each FILE to the list of $FILES.
for FILE in $FOLDER
do
FILENAME=$(basename "$FILE")
FILES=( ${FILES[@]} $FILENAME )
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment