Decompressing a .lzo file using shell script [closed]
Asked Answered
J

2

8

Ok so i did a fair bit of search on the web and did not find any answers. I am writing a shell script wherein I need to decompress a .lzo file. Do not see any leads. Anyone has any idea? I am basically reading a timestamped log file. My scripts accepts the year, month, date as arguments. I am able to locate my file but now when I have to decompress it, I have no clue how to handle a .lzo file. Help needed.

Thanks in advance.

Jayson answered 6/6, 2013 at 13:41 Comment(4)
You mention timestamps, compressed files, and a custom script but no code. Please include some code so we can see what it is you're actually trying to do.Haugen
code that I used `#!/bin/bash path="/home/vviswanathan/NEAT/" star="" dash="-" if [ $1 -gt 0 -a $2 -gt 0 -a $3 -gt 0 ] then cd $path if find $path -name "*$1-$2-$3.lzo" then echo $path$star$1$dash$2$dash$3$star lzop -d "neat*$1-$2-$3.lzo" echo "return code was $?" echo "File exists" else echo "return code was $?" echo "File does not exists" fi else echo "invalid input" fi exit 0Jayson
sorry about the formatJayson
Just edit your original question, and format it properly. Otherwise it's unreadable.Haugen
H
30

Literally what I did to figure this out:

$ apropos lzo
IO::Uncompress::AnyUncompress (3perl) - Uncompress gzip, zip, bzip2 or lzop file/buffer

Alright, so it's probably got something to do with lzop

$ lzo
No command 'lzo' found, did you mean:
 Command 'lz' from package 'mtools' (main)
 Command 'lzop' from package 'lzop' (universe)
lzo: command not found

The last one looks like it.

$ sudo apt-get install lzop
$ lzop 
[...]
Commands:
  -1     compress faster                   -9    compress better
  -d     decompress                        -x    extract (same as -dPp)

Aaand chocolate for everyone!

Haugen answered 6/6, 2013 at 13:48 Comment(4)
This has worked for me on a hadoop system but not in a shell script. Am I missing something?Jayson
What did you do, what did you get, and what did you expect?Haugen
basically have a *.dat.lzo file. I have been using lzop -d *dat..lzo to decompress the file and operate on the .dat file obtained. But now I wish to write a script to perform the same action by just passing the yyyymmdd and get back the .dat fileJayson
Sorry guys. Had not installed lzop locally. One of those bad days I guess.Jayson
T
18

Have you tried using lzop with -d command?

lzop -d file.lzo

ref: http://www.lzop.org/lzop_man.php

Regards.

Toreutic answered 6/6, 2013 at 13:50 Comment(4)
This has worked for me on a hadoop system but not in a shell script. Am I missing something?Jayson
@Jayson what kind of error did you get?Toreutic
lzop command not foundJayson
@Jayson try execute which lzop at you terminal to get the full path of lzop, then copy the full path into your script.Toreutic

© 2022 - 2024 — McMap. All rights reserved.