2

Consider we have a file named XX.zip

Use command zipinfo -1 XX.zip which shows the below content:

XX/
XX/X-Data.txt
XX/YY/
XX/YY/Zero.txt

I wanna below output instead, assume we have extracted the zip file unzip XX.zip and then use command tree XX given output:

XX
├── X-Data.txt
└── YY
    └── Zero.txt

One way to do so is write a bash command to create the hierarchy structure:

makefile ()                                                                                                                                                  
{
  while read path; do
      dir=${path%/*}
      filename=${path##*/}

      mkdir -p $dir
      if [ -n $filename ]; then
          touch $path
      fi  
  done
}

And then use commands below

 zipinfo -1 XX.zip | makefiletree 
 tree XX
 rm -rf XX

Is there any convenient way to do? any comments will be appreciated.

mipa
  • 21

0 Answers0