Skip to content

Instantly share code, notes, and snippets.

@hwpplayer1
Created February 3, 2026 10:50
Show Gist options
  • Select an option

  • Save hwpplayer1/4600ae8ded914f128f7d145ed2ee2631 to your computer and use it in GitHub Desktop.

Select an option

Save hwpplayer1/4600ae8ded914f128f7d145ed2ee2631 to your computer and use it in GitHub Desktop.
list file and directory
#!/bin/zsh
list_files() {
local path="$1"
if [[ -d "$path" ]]; then
echo "'$path' içindeki dosyalar:"
for f in "$path"/*; do
[[ -f "$f" ]] && echo "${f:t}"
done
else
echo "Hata: '$path' geçerli bir klasör değil."
fi
}
list_directories() {
local path="$1"
if [[ -d "$path" ]]; then
echo "'$path' içindeki klasörler:"
for d in "$path"/*; do
[[ -d "$d" ]] && echo "${d:t}"
done
else
echo "Hata: '$path' geçerli bir klasör değil."
fi
}
# Kullanıcıdan yol al
echo -n "Listelemek istediğin klasör yolunu gir: "
read directory_path
list_files "$directory_path"
list_directories "$directory_path"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment