Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: Print field...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 24 Topic 2212 of 2378
Post > Topic >>

Re: Print fields starting with N to the end of line.

by Ed Morton <morton@[EMAIL PROTECTED] > Mar 30, 2008 at 01:34 PM

On 3/30/2008 1:12 PM, Peter wrote:
> Hello, seems that I'm missing something obvious. There is file with
> variable number of field, is there any simple way in awk to print
> fields starting with field N up to the end of line. e.g.
> 
> $ cat test.txt
> a b c
> a b c d
> a b c d e f
> a b c d v e
> 
> How to print
> $ awk <???> test.txt
> 
> d
> d e f
> d v e
> 
> Of course this is simplification of real data I have so I definitely
> need awk to parse it ;) Thank you very much in advance.

If you don't care about white space before/between fields:

awk '{$1=$2=$3=""}1' file

If you do care, with a POSIX awk:

awk '{sub(/^[[:space:]]*([^[:space:]]*[[:space:]]*){3}/,"")}1'

and with GNU awk:

gawk --re-interval
'{sub(/^[[:space:]]*([^[:space:]]*[[:space:]]*){3}/,"")}1'

	Ed.
 




 24 Posts in Topic:
Print fields starting with N to the end of line.
Peter <volkov.peter@[E  2008-03-30 11:12:35 
Re: Print fields starting with N to the end of line.
pk <pk@[EMAIL PROTECTE  2008-03-30 20:47:04 
Re: Print fields starting with N to the end of line.
Ed Morton <morton@[EMA  2008-03-30 13:34:59 
Re: Print fields starting with N to the end of line.
"Rajan" <svr  2008-03-30 15:25:31 
Re: Print fields starting with N to the end of line.
Luuk <Luuk@[EMAIL PROT  2008-03-30 23:57:26 
Re: Print fields starting with N to the end of line.
"Rajan" <svr  2008-03-30 21:18:15 
Re: Print fields starting with N to the end of line.
Luuk <Luuk@[EMAIL PROT  2008-03-31 13:14:16 
Re: Print fields starting with N to the end of line.
pk <pk@[EMAIL PROTECTE  2008-03-31 13:48:17 
Re: Print fields starting with N to the end of line.
Luuk <Luuk@[EMAIL PROT  2008-03-31 14:01:48 
Re: Print fields starting with N to the end of line.
pk <pk@[EMAIL PROTECTE  2008-03-31 14:24:17 
Re: Print fields starting with N to the end of line.
Janis Papanagnou <Jani  2008-03-31 19:54:37 
Re: Print fields starting with N to the end of line.
Janis Papanagnou <Jani  2008-03-31 19:56:05 
Re: Print fields starting with N to the end of line.
pk <pk@[EMAIL PROTECTE  2008-04-01 09:48:02 
Re: Print fields starting with N to the end of line.
Ed Morton <morton@[EMA  2008-04-01 08:11:14 
Re: Print fields starting with N to the end of line.
Ed Morton <morton@[EMA  2008-03-31 07:03:39 
Re: Print fields starting with N to the end of line.
Luuk <Luuk@[EMAIL PROT  2008-03-31 14:10:01 
Re: Print fields starting with N to the end of line.
Ed Morton <morton@[EMA  2008-03-31 07:13:53 
Re: Print fields starting with N to the end of line.
Barry Fishman <barry_f  2008-03-31 13:45:27 
Re: Print fields starting with N to the end of line.
Ed Morton <morton@[EMA  2008-03-31 10:47:10 
Re: Print fields starting with N to the end of line.
pk <pk@[EMAIL PROTECTE  2008-03-31 18:15:35 
Re: Print fields starting with N to the end of line.
Ed Morton <morton@[EMA  2008-03-31 11:29:11 
Re: Print fields starting with N to the end of line.
Janis Papanagnou <Jani  2008-03-31 20:01:12 
Re: Print fields starting with N to the end of line.
Janis <janis_papanagno  2008-04-01 00:39:44 
Re: Print fields starting with N to the end of line.
pk <pk@[EMAIL PROTECTE  2008-04-01 10:11:43 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 14 11:27:10 CDT 2008.