Created
February 3, 2026 10:50
-
-
Save hwpplayer1/4600ae8ded914f128f7d145ed2ee2631 to your computer and use it in GitHub Desktop.
list file and 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
| #!/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