Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!ucsd!nosc!newhumu!humu!pegasus!pilikia!art From: art@pilikia.pegasus.com (Art Neilson) Newsgroups: comp.unix.xenix.sco Subject: Re: C Program Data Conversion Keywords: C program Data Message-ID: <1990Sep18.180318.19782@pilikia.pegasus.com> Date: 18 Sep 90 18:03:18 GMT References: <681@csoftec.csf.com> Organization: Pilikia, Honolulu Lines: 23 In article <681@csoftec.csf.com> cmanis@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@pilikia.pegasus.com Bank of Hawaii Tech Support | UUCP: uunet!ucsd!nosc!pegasus!pilikia!art