I have a log file that contains a lot of text, some of them are useless. There are several lines in this journal that are important to me. Template for these lines:
0x00000001 (NEEDED) Shared library: [libm.so.6] 0x00000001 (NEEDED) Shared library: [libc.so.6] 0x00000001 (NEEDED) Shared library: [ld.so.1] 0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
The NEEDED keyword can be found on all lines that are important to me. The keyword between [] is important to me. I need to create a list of all these lines without repeating them.
I did this in Python, but there seems to be no Python on the machine I want to run the script, so I need to rework the script in bash. I know only the basic things in bash, and I cannot find a solution to my problem.
Python script I used:
import sys import re def testForKeyword(keyword, line): findStuff = re.compile(r"\b%s\b" % keyword, \ flags=re.IGNORECASE) if findStuff.search(line): return True else: return False
Could you help me solve this problem? Thanks in advance.
source share