karthick kumar karthick kumar - 23 days ago 8
Linux Question

Get the filename in linux

I have LAPP.NT.APC.HIST.zip file, I'm extracting,

$ unzip LAPP.NT.APC.HIST.ZIP

Archive: LAPP.NT.APC.HIST.EXT.AUDIT.MTLY.ZIP

PKZIP for z/OS by PKWARE

inflating: LAPP.NT.APC.HIST.EXT.AUDIT1

inflating: LAPP.NT.APC.HIST.EXT.AUDIT2


how can get the specific inflating filename? If I get the filename, I want to assign into one variable like, How to do?

filename=

find . -type f -name "*.*"


echo $filename

Please help! Thank You !!!

Answer

unzip -l filename.zip will print the names, uncompressed file sizes and modification dates and times contained in an archive without inflating it.

unzip -Z1 peace.zip is more suitable here i think as it will display filenames only.

Here are the filenames contained in a zip file assigned to a variable:

files_zipped=$(unzip -Z1 filename.zip)

Comments