'How to undo extracted files by 7z

I was trying to install aws cli.

I executed the following command curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"

It downloaded to my directory awscliv2.zip

Then I installed 7zip to extract files and used the command:

7z e awscliv2.zip

It seems that 7z extracted all those files not in an aws directory, but It unfolded all files recursively without directories at all.

I've taken a screenshot to show you the issue. If I extract the file again, it shows it wants to overwrite my existing file in the root with a file which has depth 1. It somehow extracts recursively file than preserving a hierarchy of directories.

Well, I've got thousands files in my user directory and don't know how to undo the operation. 🤷‍♂️

I've tried those commands, but both of them failed.

7z l awscliv2.zip | sed 's/\(.\{53\}\)//'

7z l awscliv2.zip | awk 'BEGIN { OFS="" ; ORS="" } ; { for ( i=4; i<NF; i++ ) print $i " "; print $NF "\n" }' | xargs -I{} rm -v {}

How can I resolve this mess?

enter image description here



Solution 1:[1]

Well, I think I found a solution:

7z l awscliv2.zip | awk ' {print $6} ' | awk '
  function basename(file) {
    sub(".*/", "", file)
    return file
  }
  {print basename($1)} ' | xargs rm -rf

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 hazartilirot