For sed / awk Gurus

Rohit Mehrotra rohit at dmdev.UUCP
Thu May 23 02:53:03 AEST 1991


Hi to all SED/AWK gurus:

I am no sure how to do this:

I would have files in the following format:

Having:
1) General purpose lines of text 
2) Sections of text marked by a "~"<Section-name> at the start and
   end of the section.

What I need to do is to extract ALL the general purpose lines of text
AND the lines of the sections whose  names can be specfied as arguments 
of the shell script i.e. to syntax could be:

		shell.script FLD1 FLD2

The above script if run on the input file inp.dat would result in 
the file out.dat. 

I am enclosed both inp.dat and out.dat as shar'd files.

I would appreciate if any one could help out in creating this script
in sed (preferably) or awk.

Thanks a lot in advance.

Please EMAIL me the replies and I would post a summary.

Rohit
EMAIL: rohit%dmdev at uunet.uu.net
VOICE: 800-289-7500 ext 469

#!/bin/sh
# shar:	Shell Archiver  (v1.22)
#
#	Run the following text with /bin/sh to create:
#	  inp.dat
#	  out.dat
#
sed 's/^X//' << 'SHAR_EOF' > inp.dat &&
XThis is a test input document
Xfor creating customized reports
XThe purpose of this document
Xis to create customized reports at run time.
X
X~FLD1~  
XReport code for field1
XReport code for field1
XReport code for field1
X~FLD1~
X
XThese lines would always be there
Xas they go with all the sections.
X
X~FLD2~
XReport code for field2
XReport code for field2
XReport code for field2
X~FLD2~
X
XThese lines also would always be there
Xas they go with all the sections.
X
X~FLD3~
XReport code for field3
XReport code for field3
XReport code for field3
XReport code for field3
XReport code for field3
X~FLD3~
X
XThese lines also would always be there
Xas they go with all the sections.
X
XEnd of the report code.
SHAR_EOF
chmod 0666 inp.dat || echo "restore of inp.dat fails"
sed 's/^X//' << 'SHAR_EOF' > out.dat &&
XThis is a test input document
Xfor creating customized reports
XThe purpose of this document
Xis to create customized reports at run time.
X
XReport code for field1
XReport code for field1
XReport code for field1
X
XThese lines would always be there
Xas they go with all the sections.
X
XReport code for field2
XReport code for field2
XReport code for field2
X
XThese lines also would always be there
Xas they go with all the sections.
X
X
XThese lines also would always be there
Xas they go with all the sections.
X
XEnd of the report code.
SHAR_EOF
chmod 0666 out.dat || echo "restore of out.dat fails"
exit 0
-- 
Rohit Mehrotra
Fleet Credit Corporation
8325 NW 53rd St, Miami, Fl 33166.
E-MAIL Address rohit%dmdev at uunet.uu.net VOICE 1-(305)-477-0390 Ext 469



More information about the Comp.unix.wizards mailing list