Want to extract particular file from tar.lzo

Hi Guys,

Could you please help to get specific files from /di/data/prd/serial/lookup/abetlp11_lookup_20180206.tar.lzo without extracting whole compressed file tar.lzo as its size is huge

file name - xyz.lkp

Thanks

Operating system? Different OSs have different tools, or different flavours of the same tool.

Shell? Shells vary in their abilities and built-in commands.

Having said that, I reckon this should work (although I have no knowledge of lzop, which I assume is the program used to compress your tar file):

Find the path of the file you want to extract from the archive:

lzop -d </di/data/prd/serial/lookup/abetlp11_lookup_20180206.tar.lzo | tar -tvf - | fgrep xyz.lkp

There may be multiple files that match, so identify the file and then add it to this line:

lzop -d < /di/data/prd/serial/lookup/abetlp11_lookup_20180206.tar.lzo | tar -tvf - path/of/file/to/extract

That is, replace path/of/file/to/extract with the full line that matches your file.

Andrew

1 Like