OT: sed/awk help

Cameron Simpson cs at zip.com.au
Sat Jan 30 03:47:51 UTC 2016


On 29Jan2016 19:07, Mike Wright <nobody at nospam.hostisimo.com> wrote:
>Don't know whether this requires a "sed" and/or an "awk" solution.  I have 
>strings in a log file whose only important info for a digest are new strings 
>containing the date, time, and the remainder of the line following the first 
>occurrence of a hyphen.  All delimiters are spaces until the first hyhpen 
>(there may be multiple hyphens but I only care about the first).
>
>Here is what the original line looks like:
>
>date time txt1 txt2 txt3: txt4 txt5 txt6 txt7 domain-email
>
>Here is what I'm looking for:
>
>date time partFollowingHyphen1

Presuming date and time have no spaces, untested:

  sed 's/^\([^ ][^ ]*  *[^ ][^ ]*\) [^-]*-\(.*\)/\1 \2/'

You'll have to show us an example line if that doesn't work.

Cheers,
Cameron Simpson <cs at zip.com.au>


More information about the users mailing list