Reputation: 47
I have a text file, install.history
Wed June 20 23:16:32 CDT 2014, EndPatch, FW_6.0.0, SUCCESS
I would only need to print out the word starting from EndPatch
to the end that is FW_6.0.0, SUCCESS
The command below that I have only prints out EndPatch
, so what do I need to do so that it prints out the remaining of the words so that my result would be:
EndPatch, FW_6.0.0, SUCCESS
Here is the command that I have:
grep -oh "EndPatch[[:alpha:]]*" 'install.history'
Upvotes: 4
Views: 13164
Reputation: 97918
This is arguably, easier to do with sed
:
sed -n 's/.*EndPatch, //p' install.history
to get the word after EndPatch:
sed -n 's/.*EndPatch, \([^,]*\).*/\1/p' install.history
or:
sed -n 's/.*EndPatch, //p' install.history | cut -d, -f
Upvotes: 3
Reputation: 174696
You could try the below grep command to get everything from EndPatch
upto the last,
grep -oP 'EndPatch, (.*)$' file
or
grep -o 'EndPatch.*$' file
Example:
$ grep -oP 'EndPatch, (.*)$' file
EndPatch, FW_6.0.0, SUCCESS
$ grep -o 'EndPatch.*$' file
EndPatch, FW_6.0.0, SUCCESS
Or
You could try the below command to get all the characters which was just after to EndPatch,
$ grep -oP 'EndPatch, \K(.*)$' file
FW_6.0.0, SUCCESS
Upvotes: 1
Reputation: 41446
You can use awk
awk -F "EndPatch, " '{print FS$2}' file
EndPatch, FW_6.0.0, SUCCESS
Upvotes: 0
Reputation: 6766
You need grep -e
for regular expression matching
grep -oh 'install.history' -e "EndPatch[[:alpha:]]*"
Upvotes: 0