Getting CID of file by filename

I want to verify the file that I have is the same as that uploaded on ipfs. So I want to access the CID of a file if I have the file.

This command with --only-hash return the CID of the file then you can compare the 2.

Keep in mind that if the IPFS settings were different when the file was added the CID will be different.