sunshk1227
sunshk1227

Reputation: 219

Unzip wrongly: All files are scattered in the current directory

On CentOS, I wanted to unzip files in A.zip into ./A/. However, I didn't notice that there were hundreds of files in A.zip and I just use unzip A.zip. So now these extra files are all in the current directory. How could I solve this problem?

Thank you very much for any help!

Upvotes: 0

Views: 601

Answers (1)

Rush W.
Rush W.

Reputation: 1361

You can try this -

unzip -Z1 is the zip info mode which basically returns the files which were zipped. The output is then piped onto other command which removes that file based on the input(from the previous command).

Assuming, first you take a proper backup of that folder.

unzip -Z1 t1.zip | xargs rm -f

If the zip files has folders inside of it then

unzip -Z1 t1.zip | xargs rm -rf

t1.zip is the zip file which I tested with.

Upvotes: 1

Related Questions