. Also, each of the columns of text should be separated by spaces or tabs i.e. the first column should be the atom name "MOLYBEDUM" the second column should be the atomic number "42.0" etc...
It is always helpful to know what system you're on, so getting in the habit of posting it would be good so we don't have to ask... grep -m makes starting at a certain point easy but AIX and Solaris may not have it.
A perl solution that includes some column spacing:
$
$ cat form
#! /usr/bin/perl -wn
BEGIN {$state="skip";};
/^-+$/ and do {$state="proc"; print; next LINE};
/EQUIL/ and do {$state="copy";};
$state eq "skip" and do {next LINE;};
/^\s*$/ and do {last LINE;};
$state eq "copy" and do {print ; next LINE;};
$state eq "proc" and do { printf "%-10s %6s %16s %16s %16s\n", split(" ", $_);};
$
$
$
$ ./form < datafile | head
***** EQUILIBRIUM GEOMETRY LOCATED *****
COORDINATES OF ALL ATOMS ARE (ANGS)
ATOM CHARGE X Y Z
------------------------------------------------------------
MOLYBDENUM 42.0 5.9067578125 5.0087332497 17.4699146400
SULFUR 16.0 7.9742837782 3.7588015097 17.3910898169
SULFUR 16.0 5.0973219622 3.0091611327 16.3724427108
SULFUR 16.0 3.8536412225 4.7600928861 18.7261323168
SULFUR 16.0 6.7241053728 5.6252659948 19.6631739883
$
Yes thanks. I realize that.:o But I have more than one output file so I don't understand why there is a part on my example output file within your suggestion.
I'm not sure what the problem is. I did leave in a debug statement and I edited my post to remove it. I piped the scipt though head to cut down on the output which is why only part of your data shows. You should not use head. Run the script yourself without the head, you will see all of the data.
If you must have the perl script embedded in another language it would help if you would reveal which language. Guessing bash... here you go. But note that I'm piping through head again... you still see only part of your data.
$ cat form2
#! /bin/bash
echo I am a bash script
exec < datafile
#
#
perl -wn -e '
BEGIN {$state="skip";};
/^-+$/ and do {$state="proc"; print; next LINE};
/EQUIL/ and do {$state="copy";};
$state eq "skip" and do {next LINE;};
/^\s*$/ and do {last LINE;};
$state eq "copy" and do {print ; next LINE;};
$state eq "proc" and do { printf "%-10s %6s %16s %16s %16s\n", split(" ", $_);};
'
#
exit 0
$ ./form2 | head
I am a bash script
***** EQUILIBRIUM GEOMETRY LOCATED *****
COORDINATES OF ALL ATOMS ARE (ANGS)
ATOM CHARGE X Y Z
------------------------------------------------------------
MOLYBDENUM 42.0 5.9067578125 5.0087332497 17.4699146400
SULFUR 16.0 7.9742837782 3.7588015097 17.3910898169
SULFUR 16.0 5.0973219622 3.0091611327 16.3724427108
SULFUR 16.0 3.8536412225 4.7600928861 18.7261323168
SULFUR 16.0 6.7241053728 5.6252659948 19.6631739883
$