[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Text Manipulation



There is probbly an easier way to do this... But here is one way.
 
You could do something simple in perl like this:
 

while (<>)
{
 s/(\w\w\w\w\w\w\w)/$1 /g;
print;
}
 
This will break the line into groups of 7 characters.  You can modify this slightly to do what you want.
 
Randy 
 
 
-----Original Message-----
From: Spearing Tyler Contractor USTC
Sent: Wednesday, July 24, 2002 11:45 AM
To: 'SILUG-Discuss'
Subject: Text Manipulation

All,
 
I have racked my brains trying to figure out a way to insert
a column of white space in a plain text file several (tens of)
thousands lines long.  The problem is there is no common text
before or after the column I need to insert the blank space.
 
For example, take the following block of text:
 
12345ABCDE67890FGHJK
Q1W2E3R4T5Y6U7I8O9P0
MNBHGVFRT7352508HY7S
THISLINEHASNOBLANKS2
ANOTHERLINEWITHNONE5
1MORELINEWITHNONEZZZ
 
I would like to insert a column (or two) of white space to
essentially create fields to be manipulated with NAWK, so
that the above text would look like the following:
 
12345AB CDE67890F GHJK
Q1W2E3R 4T5Y6U7I8 O9P0
MNBHGVF RT7352508 HY7S
THISLIN EHASNOBLA NKS2
ANOTHER LINEWITHN ONE5
1MORELI NEWITHNON EZZZ
 
I can use PERL, if necessary, but have a preference for either a shell script or SED command, etc..
 
Any ideas?

Thanks in advance,

Tyler