I am trying to find the largest file in a directory recursively. If there is a subdirectory inside of that directory the function needs to go inside that directory and check to see if the largest file is there. Once the largest file is found the output is displayed with the relative path name and the name and size of the largest file.
EX:
dude@shell2 (~...assignment/solutions) % bash maxfile.sh ~/test
class/asn
dude.h.gch: 9481628
This is what I have:
#!/bin/sh
clear
recursiveS() {
for d in *; do
if [ -d $d ]; then
(cd $d; echo $(pwd)/$line; du -a; recursiveS;)
fi
done
}
recursiveS
I have been stuck for a while now. I cannot implement this by pipelining a number of existing Unix tools. Any ideas would be nice!
for d in */ .[^.]*/
; do ...`