I am writing a script (bash/command-line) and I want to be able to extract the package name until .el7
x=dbus-sharp (an example package name - which changes)
example text file:
Building dbus-sharp-0.7.0-11.fc22 for epel7 Created task: 7970206 ... 0 free 1 open 1 done 0 failed 7970225 buildArch (dbus-sharp-0.7.0-11.el7.src.rpm, ppc64): free 7970223 buildArch (dbus-sharp-0.7.0-11.el7.src.rpm, x86_64): open (buildhw-03.phx2.fedoraproject.org) ...
basically now I want
It doesn't matter if I need to use grep, sed or awk.
I haven't had any luck googling for a similar solution.
Examples I have tried:
[me@h dbus-sharp]$ echo "Here is a String" | grep -Po '(?<=(Here )).*(?= String)' is a [me@h dbus-sharp]$ cat scratchdbus-sharp | grep -Po '(?<=(dbus)).*(?= el7)' (no output?) [me@h dbus-sharp]$ cat scratchdbus-sharp | awk '/dbus/,/el7/' (it dumps the whole text file?) [me@h dbus-sharp]$ sed -n "/dbus/,/el7/p" scratchdbus-sharp (again the whole text file is dumped) [me@h dbus-sharp]$ grep -m 1 "dbus-sharp" scratchdbus-sharp Building dbus-sharp-0.7.0-11.fc22 for epel7
Guess I should also note that epel7 will be in the text file(s) which will also cause a match for 'el7' complicating things.