-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdirectoryList.sh
More file actions
executable file
·30 lines (26 loc) · 878 Bytes
/
directoryList.sh
File metadata and controls
executable file
·30 lines (26 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh
########################
# Makes a list of subdirectories and their full paths
# format will come out like:
# /path/to/dir/nameOfDir nameOfDir/
#
# Ex: ./directoryList.sh > output.txt
#
# Notes:
# Will cause issues with directories that have spaces in their names
# Do not use with dirs with spaces in their names
########################
#Variables
# Insert the directory that you want to create the output for
Directory="/usr/local/git/testSplit/"
directoryListing()
(
# use the parameter passed to this function in $1, or if nothing passed in, use "." (current dir)
cd "${1:-.}" || return
# for each directory in the current directory
for directory in */; do
# print full path of dir AND directory name only (without trailing slash)
printf "%s %s\n" "$PWD/$directory" "${directory%/}"
done
)
directoryListing $Directory