mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-06-17 02:25:12 -05:00
feat: init
This commit is contained in:
commit
c19ea940bd
320 changed files with 23845 additions and 0 deletions
27
profiles/user0/files/list.sh
Executable file
27
profiles/user0/files/list.sh
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Function to list directories recursively and sort them alphabetically
|
||||
list_directories() {
|
||||
local parent_dir=$1
|
||||
local output_file=$2
|
||||
|
||||
# Clear the output file if it exists
|
||||
> "$output_file"
|
||||
|
||||
# Recursively find and list directories, then sort them and write to the output file
|
||||
while IFS= read -r dir; do
|
||||
echo "$dir" >> "$output_file"
|
||||
done < <(find "$parent_dir" -type d | sort)
|
||||
}
|
||||
|
||||
# Main script execution
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: $0 parent_directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
parent_directory=$1
|
||||
output_file="nested_directories.txt"
|
||||
|
||||
list_directories "$parent_directory" "$output_file"
|
||||
echo "Directory paths have been written to $output_file"
|
Loading…
Add table
Add a link
Reference in a new issue