How do I name one random file in the deepest level of a directory tree using basic Bash commands and script?
I was searching for a way to do it as an one-liner and without functions. Assuming also that I'm starting in the current directory and then work towards the depth.
awk are acceptable commands.
My current attempt looks like this and does not work:
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
This would only find the directory.
How could this be solved in the most simple way?