removeing first 3 columns from the lines in file

A

ajay

In log file i have lines like this:

01-22T09:26:24.560 [00504] (tShell) {0xd071920}
Alcap_menu::send_establish_response] | SUCCESS

It's single line. now i want to remove first 3 columns( better to say
first 3 set of strings seperated by spaces) of line and retain rest of
line, i.e I want to have only this:

Alcap_menu::send_establish_response] | SUCCESS

How to do it in a single perl command ?

Tx
 
S

Sam Holden

In log file i have lines like this:

01-22T09:26:24.560 [00504] (tShell) {0xd071920}
Alcap_menu::send_establish_response] | SUCCESS

It's single line. now i want to remove first 3 columns( better to say
first 3 set of strings seperated by spaces) of line and retain rest of
line, i.e I want to have only this:

Alcap_menu::send_establish_response] | SUCCESS

How to do it in a single perl command ?

Does preserving exact whitespace matter?

perl -lane 'print "@F[3..$#F]"'

If it does:

perl -pe "s/^\S+\s+\S+\s+\S+//"

Or the now leading space should also go:

perl -pe "s/^\S+\s+\S+\s+\S+\s+//"

replace \s+ with ' ' or \t or whatever if the whitespace is more
restrictively defined (which would allow \S* to be useful for empty
fields...)
 
A

ajay

Tx Sam it works
This is the command which solves my purpose.

perl -pi -e "s/^\S+\s+\S+\s+\S+\s+\S+\s+//" log_file


Sam said:
In log file i have lines like this:

01-22T09:26:24.560 [00504] (tShell) {0xd071920}
Alcap_menu::send_establish_response] | SUCCESS

It's single line. now i want to remove first 3 columns( better to say
first 3 set of strings seperated by spaces) of line and retain rest of
line, i.e I want to have only this:

Alcap_menu::send_establish_response] | SUCCESS

How to do it in a single perl command ?

Does preserving exact whitespace matter?

perl -lane 'print "@F[3..$#F]"'

If it does:

perl -pe "s/^\S+\s+\S+\s+\S+//"

Or the now leading space should also go:

perl -pe "s/^\S+\s+\S+\s+\S+\s+//"

replace \s+ with ' ' or \t or whatever if the whitespace is more
restrictively defined (which would allow \S* to be useful for empty
fields...)
 
A

Anno Siegel

ajay said:
Tx Sam it works
This is the command which solves my purpose.

perl -pi -e "s/^\S+\s+\S+\s+\S+\s+\S+\s+//" log_file

(Please don't top-post)

This is clearer, imo:

perl -p -e '(split " ", $_, 3)[ 2]' log_file

Anno

[TOFU snipped]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top