How to name a file in the deepest level of a directory tree
How do I get this script to work? The goal is to find the directory at the deepest level in the directory tree and print the name of a file, a random file, maybe the first.
find -type d | declare COUNT=-1; declare P=""; while read LINE ; do echo $LINE declare C C=$(echo $LINE | cut -c3- | sed "s/\//\n\//g" | grep '/' -c) echo $C if [ $COUNT -gt $C ] then let COUNT=$C let P=$LINE echo "Done" fi done
Better solutions are also welcome but they should be one-liners.