linuxbashshellunixlzo

uncompressed .lzo file and then delete .lzo file


I have a LZO compressed file in two directories which I need to uncompressed it and then delete all the LZO compressed file.

So I have LZO compressed file in /test01/primary folder which I need to uncompressed it and then delete all the .lzo files. Same thing I need to do in /test02/secondary folder as well. I will have around 150 LZO files in both folder so total around 300 files.

From a command line I was running like this to uncomressed one file lzop -d file_name.lzo.

What is the fastest way to uncompressed all LZO file and then delete all .lzo file from both the folders.

#!/bin/bash

set -e

export PRIMARY=/test01/primary
export SECONDARY=/test02/secondary

lzop -d $PRIMARY/*
lzop -d $SECONDARY/*

# now delete?

May be we can parallelly "uncompressed LZO file and then delete all .lzo file" in both the folders simultaneously to speed up the process.


Solution

  • You can parallel it like so:

    lzop -d $PRIMARY/* & lzop -d $SECONDARY/*
    

    and then delete all the .lzos like this:

    find $PRIMARY $SECONDARY -name '*.lzo' -delete
    

    hope this helps!