to the end of line... 
Author Message
 to the end of line...

cut -b8-

--> char n8 to the end of line --> OK

awk '{print $8 $9 $10 $11 $12 $13 ...}'

--> field n8 to the end of line --> hum...

I beg thee for any SMARTER solution ?

--
AL



Wed, 04 Apr 2001 03:00:00 GMT  
 to the end of line...


Quote:
>cut -b8-

>--> char n8 to the end of line --> OK

>awk '{print $8 $9 $10 $11 $12 $13 ...}'

>--> field n8 to the end of line --> hum...

>I beg thee for any SMARTER solution ?

gawk '{for(i=8;i<=NF;i++){printf "%s%s",$i, i < NF ? " " : "\n"}}'

which separates the fields by single spaces, whereas your print
statement pastes the fields together.

Alternatively, this doesn't reformat the field spacing:

gawk '{for(i=1;i<8;i++){sub(/^[ \t]*[^ \t]*[ \t]/};print}'

Chuck Demas
Needham, Mass.

--
  Eat Healthy    |   _ _   | Nothing would be done at all,

  Die Anyway     |    v    | That no one could find fault with it.



Wed, 04 Apr 2001 03:00:00 GMT  
 to the end of line...

Quote:

>>cut -b8-

>>--> char n8 to the end of line --> OK

>>awk '{print $8 $9 $10 $11 $12 $13 ...}'

>>--> field n8 to the end of line --> hum...

>>I beg thee for any SMARTER solution ?

How about:

awk '{for (i = 8; i <= NF; i++) {print $i}}'

or, for output with one line corresponding to one input line:

awk '{for (i = 8; i <= NF; i++) {printf "%s ",$i}; print""}'

or:

cut -f8-

--
Greg

http://www.mastnet.net/~jupiter



Wed, 04 Apr 2001 03:00:00 GMT  
 to the end of line...

Quote:

> cut -b8-

> --> char n8 to the end of line --> OK

> awk '{print $8 $9 $10 $11 $12 $13 ...}'

> --> field n8 to the end of line --> hum...

> I beg thee for any SMARTER solution ?

> --
> AL

If you know that the contents of field 8 will not appear in another field before
you can try

gawk '{match($0,$8);print(substr($0,RSTART)}'

Cesar
--
Please remove the uppercase characters from my e-mail address for the real thing



Wed, 04 Apr 2001 03:00:00 GMT  
 to the end of line...

Quote:

> --> char n?8 to the end of line --> OK

> awk '{print $8 $9 $10 $11 $12 $13 ...}'

> --> field n?8 to the end of line --> hum...

awk 'BEGIN {ORS=""}
{for (k=8;k<NF;k++) {print $(k) " "}; print $(NF) "\n"}' inFile>outFile

This does not retain large white space between the fields.

LMS
free sed/awk book:
      ftp://ftp.u-aizu.ac.jp/u-aizu/doc/Tech-Report/1997/97-2-007.ps.gz
      ftp://ftp.u-aizu.ac.jp/u-aizu/doc/Tech-Report/1997/97-2-007.tar.gz



Wed, 04 Apr 2001 03:00:00 GMT  
 to the end of line...
It should have read

gawk '{match($0,$8);print(substr($0,RSTART))}'

instead of

Quote:
> gawk '{match($0,$8);print(substr($0,RSTART)}'

Anyway, this is a good solution if you can be certain that the contents of field 8
will not appear in the previous fields because it should work fast and maintains
your formatting. Depending on the data, perhaps this field content uniquness can
be guaranteed simply because of the field contents. If field 8 contains a date,
for example "16/10/98", then if fields 1 to 7 are not data fields, you can trust
this code to do what you require. If, however, one of the fields 1 to 7 also
contains a date and that date is the same as in field 8, then match will find that
field first. This also applies to substrings (i.e. if field 8 is a substring of
any of the fields 1 to 7) then this will not work.

Cesar
--
Please remove the uppercase characters from my e-mail address for the real thing



Wed, 04 Apr 2001 03:00:00 GMT  
 to the end of line...
Quote:
>Subject: to the end of line...
....
>cut -b8-

>--> char n8 to the end of line --> OK
....
>awk '{print $8 $9 $10 $11 $12 $13 ...}'

>--> field n8 to the end of line --> hum...

>I beg thee for any SMARTER solution ?

....

Why not  cut -f8-  ?



Sat, 07 Apr 2001 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Newbie: dots ending last line of a method

2. Removing End of Line and carrige return

3. Question: How to remove END OF LINE using AWK or SED

4. Detecting end-of-line when reading a FILE?

5. Memo File, CHR(end-of-line)??

6. PARSE, WORD and end of line in files

7. PARSE, WORD and end of line in files

8. Net::HTTP socket performing end-of-line conversion?

9. how to check for end-of-line?

10. Comments at the End of Lines

11. Solution to READ statement not recognising end of line

12. READ statement not recognising end of line??

 

 
Powered by phpBB® Forum Software