5

I wrote a compressing command in Ubuntu. However,the zip file produced also contain path folder leading to the target file in form of folder. I only need the target file alone in the zip file. This is the code I currently using.

zip -9pr /mnt/test/Raimi/temp/Testing.zip /home/tect/Loco/*txt

where mnt/test/Raimi/temp is the destination folder Testing.zip is the output I intended to produced and /home/tect/Loco is the Original file located.

Please help pointed out a fault in my command if found. Thank you in advance.

1 Answers1

8

The -j (--junk-paths) option of zip is there exactly for this purpose.

From man zip:

-j --junk-paths

Store just the name of a saved file (junk the path), and do not store directory names. By default, zip will store the full path (relative to the current directory).

So, do:

zip -9jpr /mnt/test/Raimi/temp/Testing.zip /home/tect/Loco/*txt
heemayl
  • 56,300