Last active
January 13, 2025 10:55
-
-
Save yeiichi/8aa4306865e9d24dde7aafdc98d33cd5 to your computer and use it in GitHub Desktop.
Display a numbered file list of a specified directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
my_name=$(basename "$0") | |
display_help() { | |
cat <<EOF | |
${my_name}: | |
Display a numbered file list of a specified directory. | |
EOF | |
} | |
main() { | |
# display_help | |
printf 'DIR? >> ' | |
read -r target_dir | |
count=1 | |
for i in "${target_dir}"/*; do | |
printf '%3d: %s...\n' "${count}" "${i:0:64}" | |
count="$((count + 1))" | |
done | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment