Path: utzoo!attcan!uunet!murphy!jpr From: jpr@murphy.com (Jean-Pierre Radley) Newsgroups: comp.unix.xenix.sco Subject: Re: C Program Data Conversion Keywords: C program Data Message-ID: <1990Sep19.013536.25199@murphy.com> Date: 19 Sep 90 01:35:36 GMT References: <681@csoftec.csf.com> Organization: Murphy & Durieu Lines: 30 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. > >/below is a sample of datafile/ >1990 aaa bbbbb ccc ddd eeeeeee fff >ggggg >1990 aaa bbb ccccccccc ddd eee fff >gggggggggg >1990 aaa bbb ccc ddddddd eee fff >ggggggg >There must be a million ways to do this, but I only need one ! ! A C-program sounds like overkill. Why not use 'awk'? awk datafile ' /^1990/ { FIRSTPART = $0 ; next } { printf "%s %s\n", $FIRSTPART, $0 } ' > newdatafile BTW, why is this question in a newsgroup with 'sco' in its name? Sounds like a pretty general Unix question. -- Jean-Pierre Radley jpr@jpradley CIS:72160,131