I have a cache file containing text and paths to Linux files. I would like to extract these files using Linux regex, but I'm not sure how to do it. Here is a sample of what the cache file looks like:
/usr/bin/mk_cmds (not prelinkable)
/usr/bin/gcov:
/lib/libc-2.5.so [0xfff88e55]
/lib/ld-2.5.so [0x7e786fcc]
/usr/lib/rpm/rpmdeps:
/usr/lib/librpmbuild-4.4.so [0xdb141354]
/usr/lib/librpm-4.4.so [0x4d8c8840]
Now here is what I would like to extract:
/usr/bin/mk_cmds
/usr/bin/gcov
/lib/libc-2.5.so
/lib/ld-2.5.so
/usr/lib/rpm/rpmdeps
/usr/lib/librpmbuild-4.4.so
/usr/lib/librpm-4.4.so
I tried a few things but none of them work (using grep):
^(.*/)?(?:$|(.+?)(?:(\.[^.]*$)|$))
'(\/.+?) '
Do you have any idea how I could do it? I have tried a few things but nothing worked. Thank you very much
regexas well as the way you use to extract them (bash,pythonetc..)grepcan handle 3 different kinds of regular expressions. For instance, the+you are using, would not work with grep's basic regular expressions. See the options-Eand-Pin grep./character and don't contain a white space or:character:grep -o '/[^[:space:]:]*' cachefile