Find the answer to your Linux question:
Results 1 to 1 of 1
I'm trying to add all ubuntu packages list to an sqlite database. Everything works out perfectly, I wget http://archive.ubuntu.com/ubuntu/dis...6/Packages.bz2 and I managed to make each line as an INSERT command. ...
  1. #1
    Just Joined!
    Join Date
    Jun 2008
    Location
    Serbia
    Posts
    3

    problem checking/adding lines - sed?

    I'm trying to add all ubuntu packages list to an sqlite database.
    Everything works out perfectly, I wget http://archive.ubuntu.com/ubuntu/dis...6/Packages.bz2 and I managed to make each line as an INSERT command.

    The problem is that some parts of the list aren't always shown, specifically after "Version:"
    Replaces:
    Provides:
    Depends:
    Recommends:
    Suggests:
    Conflicts:
    and after "Origin:"
    Task:
    e.g. I need to add "Replaces:" in a new line after a line that starts with "Version:" only if there isn't such a line (that begins with "Replaces:")

    I've tried a sed script, but I think I have it all wrong:
    Code:
    s/"/'/g
    :replaces
    s/Replaces: /","/g
    t provides
    T addreplaces
    :addreplaces
    /Version:/ a\
    Replaces:
    :provides
    s/Provides: /","/g
    t depends
    T addprovides
    :addprovides
    /Replaces:/ a\
    Provides:
    :depends
    s/Depends: /","/g
    t next
    T adddepends
    :adddepends
    /Version:/ a\
    Depends:
    :next
    I've attached a small sample of the packages.bz2 (uncompressed) for you to play with.

    Thanks in advance!
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...