Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading only certian fields with substr and skipping the rest

Status
Not open for further replies.

jkluesner

Technical User
Sep 29, 2006
24
US
Hello agian,

Thanks for the help on my last question. Ok, I have a printf statement that reads certian feilds using substr. I use this because the raw data has no spaces or commas....just a bunch of numbers. This is the printf I use:

#!/usr/bin/awk -f

{
printf "%s %s %s %s%s %s%s", substr($0,7,2), substr($0,4,2), substr($0,1,2) + 2000, substr($0,10,2), substr($0,13,2), substr($0,27,10), substr($0,38,12)
}

this works but the format is lines up side by side. I want only one set of columns for each field ....not multiple. This is what I get for output:

3.8690,111 33.1720 05 09 2006 0510 27 3.8610,111 33.1550 05 09 2006 0511 27 3.8520,111 33.1350 05 09 2006 0511 27 3.8430,111 33.1160 05 09 2006 0511 27 3.8330,111 33.0960 05 09 2006 0511 27 3.8240,111 33.0760 05 09 2006 0511 27 3.8140,111 33.0560 05 09 2006 0512 27 3.8040,111 33.0350 05 09 2006 0512 27 3.7940,111 33.0160 05 09 2006 0512 27 3.7830,111 32.9960 05 09 2006 0512 27 3.7720,111 32.9770 05 09 2006 0512 27 3.7610,111 32.9580 05 09 2006 0513 27 3.7500,111 32.9380 05 09 2006 0513 27 3.7390,111 32.9180 05 09 2006 0513 27 3.7280,111 32.8990 05 09 2006 0513 27 3.7180,111 32.8790 05 09 2006 0513 27 3.7070,111 32.8600 05 09 2006 0514 27 3.6980,111 32.8400 05 09 2006 0514 27 3.6880,111 32.8200 05 09 2006 0514 27 3.6790,111 32.7990 05 09 2006 0514 27 3.6700,111 32.7780 05 09 2006 0514 27 3.6610,111 32.7580 05 09 2006 0515 27 3.6510,111 32.7370 05 09 2006 0515 27 3.6400,111 32.7150 05 09 2006 0515 27 3.6300,111 32.6960 05 09 2006 0515 27 3.6190,111 32.6760 05 09 2006 0516 27 3.6090,111 32.6570 05 09 2006 0516 27 3.5980,111 32.6380 05 09 2006 0516 27 3.5870,111 32.6190 05 09 2006 0516 27 3.5770,111 32.6000 05 09 2006 0516 27 3.5660,111 32.5800 05 09 2006 0517 27 3.5550,111 32.5590 05 09 2006 0517 27 3.5440,111 32.5400 05 09 2006 0517 27 3.5340,111 32.5210 05 09 2006 0517 27 3.5230,111 32.5010 05 09 2006 0517 27 3.5140,111 32.4830 05 09 2006 0517 27 3.5040,111 32.4630 05 09 2006 0518 27 3.4950,111 32.4430 05 09 2006 0518 27 3.4860,111 32.4220 05 09 2006 0518 27 3.4770,111 32.4020 05 09 2006 0518 27 3.4660,111 32.3820 05 09 2006 0518 27 3.4550,111 32.3630 05 09 2006 0519 27 3.4440,111 32.3440 05 09 2006 0519 27 3.4330,111 32.3250 05 09 2006 0519 27 3.4230,111 32.3050 05 09 2006 0519 27 3.4120,111 32.2850 05 09 2006 0519 27 3.4030,111 32.2650 05 09 2006 0520 27 3.3950,111 32.2450 05 09 2006 0520 27 3.3850,111 32.2240 05 09 2006 0520 27 3.3750,111 32.2050 05 09 2006 0520 27 3.3640,111 32.1860 05 09 2006 0520 27

I want only one set that runs from top to bottom. Is there a simple next or skip command I could put in that would skip the rest of each input line and start a new line?

Thanks!!
 
Never mind guys.....I got it. Just needed to add \n

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top