Answer the question
In order to leave comments, you need to log in
How to form a regular expression?
There is a text file containing a log of package manager actions (for Debian /var/log/dpkg.log). It is necessary to pull out from it the names of installed packages for the last three days. A few lines from the file:
2014-11-18 10:02:29 startup archives unpack
2014-11-18 10:02:29 install xutils-dev:amd64 <нет> 1:7.7~1
2014-11-18 10:02:29 status half-installed xutils-dev:amd64 1:7.7~1
Answer the question
In order to leave comments, you need to log in
Why do you need a regular expression here?
Here's a Python script for you:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
fromDate = '2014-11-15'
for line in open('/var/log/dpkg.log'):
date, time, action, name, other = line.split(' ', 4)
if date >= fromDate and action == "install":
print(name)
(?=[a-zA-z])\b\w+-?\w+\b(?=:)
or(install|installed) \w+-?\w+\b(?=:)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question