Cutting input with cut or awk?

1

I'm basically trying to parse raw IRC input with a bash script, and I want to grab the messages, and nothing else. An example of what I'm trying to save is

:user!~name@host.name PRIVMSG #channel :this is the message

So, I thought that this would be fine, and I could just use 'cut' for the challenge. I went on to use cut -d ':' -f3 but soon found that if a user posted something with a ':' in it, it would ruin the 'parsing' How else could I go about getting just the message?

hjfitz

Posted 2014-03-04T21:34:24.980

Reputation: 11

Answers

1

You can specify a range of fields. To get from field 3 to the end: cut -d: -f3-

$ line=':user!~name@host.name PRIVMSG #channel :this is the message: all of it'
$ echo "$line" | cut -d: -f3
this is the message
$ echo "$line" | cut -d: -f3-
this is the message: all of it

glenn jackman

Posted 2014-03-04T21:34:24.980

Reputation: 18 546