C Program Data Conversion

Art Neilson art at pilikia.pegasus.com
Wed Sep 19 04:03:18 AEST 1990


In article <681 at csoftec.csf.com> cmanis at csoftec.csf.com (Cliff Manis) writes:
>
>                I need help in writing a 'C' program
>
>I need help in writing a 'C' program to do the following.  It must be simple
>but I can't seem to get it working.  Below is a datafile which in which 
>line 1 always starts with "1990" and it ends with a carriage return, and
>goes to line two of that data record.  The data separators are spaces.
>
>All I want to do is:  If the line start with "1990", move to the end, delete
>the carriage return, put in a space, and append the second line.

Here's an awk solution, I'm sure someone will post something in perl ...
stick the statements below into a file and chmod +x file.

:
awk '
	$0  ~ /^1990/	{ rec_1990 = $0 }
	$0 !~ /^1990/	{ print rec_1990 " " $0 }
' < $1
-- 
Arthur W. Neilson III		| ARPA: art at pilikia.pegasus.com
Bank of Hawaii Tech Support	| UUCP: uunet!ucsd!nosc!pegasus!pilikia!art



More information about the Comp.unix.xenix.sco mailing list