IPFS Get Hash of Uploaded directory from CLI

I have uploaded a directory of files to IPFS, using the command
ipfs add -r .

But after the upload is successful, I’d need to obtain the last hash of the above process.
ie. if the directory name is public, then there would be a hash corresponding to it.

I tried ipfs files stat \public and ipfs files stat \
But both didn’t work.

Any help would be greatly appreciated.
Thanks

You are supposed to note it when add returns.
Anyway it’s stored in ipfs pin ls --type=recursive (altho good luck finding it)

Yes. I can note it down.
But I’m trying to automate the process, and would like to build it in some Shell script.