Is there any way to find the compressed size of a file without compressing it in linux

i need to backup a directory from one partition to another and and compress that directory after backing up, so i need to predict the compressed size of the directory with out actually compressing it, to check whether the space is available in the destination partition to accommodate the zipped file. is there any way ?

Well, if you mean without uncompressing, it is a function of the tools that compressed the file. Check the man pages for the uncompression tool, to see if it has some list option. Also, you can uncompress to a pipe to wc: "gzcat file | wc -c | read csize", so you uncompress using CPU but need no space for the product.

If you mean the length of a potential compressed version of an uncompressed file, no, but you can do a similar pipe deal" "compress < file | wc -c | read csize"

How well a file compresses depends on its contents, so it's quite difficult to tell in advance. Text tends to compress relatively well. Binary files much less so, though that depends on their composition.