I obviously haven't learned my lesson with shell and whitespace.
find /path/to/some/where/ -name "*.pdf" | awk '{print $5}'| uniq -d
results:
some Corporation
other Corporate junk
firmx
Works fine from cmdline but the whitespace turns into another FS in a for loop.
for i in ` find /path/to/some/where -name "*.pdf" | awk -F/ '{print $5}'| uniq -d`;do echo $i; done
returns:
some
Corporation
other
Corporate
junk
firmx
Can't see how you got two fields from your awk '{print $5} .
Please post some sample output from the following find statement (note the single quotes instead of double quotes):
In many circumstances the output will be identical.
I was more interested in what the output looked like.
Your first example does not have a "-F /" delimiter flag to awk. I cannot see how the command as posted could produce the output as posted.
I guess you are looking for unique subdirectory names at the 4th level where a subdirectory contains files of name *.pdf. Combining the various ideas above and refining the final display to preserve spaces we get:
#!/bin/ksh
find /path/to/some/where/ -type f -name '*.pdf' -print | \
awk -F/ '{print $5}'| sort | uniq -d | while read name
do
echo "${name}"
done