changing all the lines in one format

Hi,

I am beginner. have almost one text file which contains 6000 lines. every line is in different format.so need to rearrange in single format.

Ex: .thde.adgtmk.802ati
thde.kghijk..567ati
..thde.kghijk..458ati
thde.ertyui.456.567.789ati
thde.awse.dati

Rules:
1.no line should start with '.' or '..'
2.if line contains more 11characters then need add one space after that(if 12th character is '.' then need replace with one space other wise add one space)
3.if 12th and 13th both are '.' then replace with one space.
4.if line contains like - thde.ertyui.456.567.789ati

then need to replace like
thde.ertyui 456ati
thde.ertyui 567ati
thde.ertyui 789ati

5.if line contains - thde.awse.dati
then thde.awse dati
every line should contain 11character then either '.' or '..'
if line have 4 characters then '.' then 5 characters so totally 10 characters only have then 11 character has to insert as space.

so finally output should appear like

thde.adgtmk 802ati
thde.kghijk 567ati
thde.kghijk 458ati
thde.ertyui 456ati
thde.ertyui 567ati
thde.ertyui 789ati
thde.awse dati

It would be great if i get the solution ASAP :slight_smile:
Thanks a lot...:slight_smile:

---------- Post updated at 08:17 PM ---------- Previous update was at 05:08 PM ----------

I am using AIX/unix.....if it could done with AWK and SED .....really it would be great.... :slight_smile:

$
$ cat f1.in
.thde.adgtmk.802ati
thde.kghijk..567ati
..thde.kghijk..458ati
thde.ertyui.456.567.789ati
thde.awse.dati
$
$ ##
$ perl -lne 's/^\.{1,2}//;
>   if (/^(\w{4}\.\w{4,6})\.+(\w+)$/) {$_ = "$1 $2"}
>   elsif (/^(\D+)\.(\d+)\.(\d+)\.(\d+)(\D+)$/) {$_ = "$1 $2$5\n$1 $3$5\n$1 $4$5"}
>   print' f1.in
thde.adgtmk 802ati
thde.kghijk 567ati
thde.kghijk 458ati
thde.ertyui 456ati
thde.ertyui 567ati
thde.ertyui 789ati
thde.awse dati
$
$

tyler_durden

while(<DATA>){
	chomp;
	s/^\.*//;
	if(/thde.awse.dati/){
		print $_,"\n";
	}
	elsif(/^(.{11})\.+([^.]+$)/){
		print $1," ",$2,"\n";
	}
	else{
		my @tmp=split("[.]",$_);
		my @t1=split(/(?=[^0-9]*$)/,$tmp[$#tmp],2);
		my @final=(@tmp[2..$#tmp-1],$t1[0]);
		my $suffix=$t1[1];
		map {print $tmp[0],".",$tmp[1]," ",$_,$suffix,"\n"} @final;
	}
}
__DATA__
.thde.adgtmk.802ati
thde.kghijk..567ati
..thde.kghijk..458ati
thde.ertyui.456.567.789ati
thde.awse.dati