cmanis@csoftec.csf.com (Cliff Manis) (09/18/90)
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.
Now that really sounds simple - doesn't it ? ? ? But, I am trying to convert
some data, and need help !
/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 ! !
Thanks, for any help ! ! Cliff Manis
_
Standard Disclaimer: We are not associated with anyone. (PERIOD). (.)
| INTERNET: cmanis@csoftec.csf.com UUCP: swrinde!csoftec!cmanis |
_=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=_
art@pilikia.pegasus.com (Art Neilson) (09/19/90)
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
jpr@murphy.com (Jean-Pierre Radley) (09/19/90)
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
andrew@teslab.lab.OZ (Andrew Phillips 289 8712) (09/27/90)
In article <1990Sep19.013536.25199@murphy.com> jpr@murphy.com (Jean-Pierre Radley) writes: >A C-program sounds like overkill. Why not use 'awk'? It would be even simpler to use a keystroke macro in Epsilon (or Emacs or whatever). -- Andrew Phillips (andrew@teslab.lab.oz.au) Phone +61 (Aust) 2 (Sydney) 289 8712