Is this a one-time or re-occuring task? If is just a one time job, it is easier to just create the directories manually than writing a script for parsing this input file.
The -p switch of mkdir might come handy when creating the directories.
My apologies, I mean File and Directory Structure is my current structure directory, but i want to generate a full path of file and directory structure and print to a file, not to create a directory
thanks for response
---------- Post updated 02-21-13 at 10:19 AM ---------- Previous update was 02-20-13 at 06:43 PM ----------
Each directory component is broken out and put into a array (found[] in first script and v[] in second)
Each element in the array counts how many children sit below it
Now if a new directory or file ./files/Share/dirX is processed the count in v[./files/Share] will be incremented to 12 because no entry exists for v[./files/Share/dirX] this allows the output of 1.12.1 dirX to be printed.
Actually, find doesn't even guarantee that. No assumptions can be made.
For some reason, this little problem interested me (not the sorting, but generating the indices). Borrowing your find , here's my attempt at a recursive AWK solution:
find ./files \( -type d -o -name "*.abc" -o -name "*.txt" \) | awk -F'/+[^/]' '
function ppath(n,b,i,s) {
do {
s = b "." ++i
print s " " $0
if (getline != 1) exit
if (n < NF) ppath(NF, s)
} while (n == NF)
}
NR == 1 { print 1 " " $0 }
NR == 2 { ppath(NF, 1) }'
My once a year perl diversion:
perl -lpaF/+ -e '$b=$#F if $.==1; $n=$#F-$b; $a[$n]=0 if $n>$o; $a[$o=$n]++; printf "%s ", join(".", @a[0..$n])'