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.

Vikas
  • 704
  • 1
  • 6
  • 13
  • You mention timestamps, compressed files, and a custom script but no code. Please include some [code](http://pscode.org/sscce.html) so we can see what it is you're actually trying to do. – l0b0 Jun 06 '13 at 14:04
  • 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 0 – Vikas Jun 06 '13 at 14:05
  • sorry about the format – Vikas Jun 06 '13 at 14:06
  • 1
    Just edit your original question, and format it properly. Otherwise it's unreadable. – l0b0 Jun 06 '13 at 14:06

2 Answers2

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!

l0b0
  • 55,365
  • 30
  • 138
  • 223
  • This has worked for me on a hadoop system but not in a shell script. Am I missing something? – Vikas Jun 06 '13 at 13:54
  • What did you do, what did you get, and what did you expect? – l0b0 Jun 06 '13 at 13:56
  • 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 file – Vikas Jun 06 '13 at 14:00
  • Sorry guys. Had not installed lzop locally. One of those bad days I guess. – Vikas Jun 06 '13 at 14:08
18

Have you tried using lzop with -d command?

lzop -d file.lzo

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

Regards.

wizard
  • 1,456
  • 1
  • 11
  • 20