small correction.. there can be more than 2 byte space between 2 columns...
it should replace with delimiter '|' if it has two consecutive spaces .. not just one..
as the first column has single spaces in it "Some kind of text" .. this is one single record...
-thanks
i will correct the loop position..thanks for that jim...
hey sb008.. im writing a perl script.. not a shell.. but still thanks for ur suggestion.. i can use it when i do a shell ..
if part of a larger script local-ize the global perl variables so they do not mess around with any other parts of the program that might use them (if any):
{
local @ARGV = ($chk_file);
local $^I = '.bak';
while (<>){
s/ {2,}/|/g;
print;
}
}
Some kind of text 1234567891 abcd February 14, 2008 03:58:54 AM 0.00 descr lmnop
Some kind of text 1234567891 abcd February 14, 2008 03:58:54 AM 0.00 lmnop
Some kind of text 1234567891 abcd February 14, 2008 03:58:54 AM 0.00
Im looking for a code that does something like this ..
Some kind of text 1234567891|abcd|February 14, 2008 03:58:54 AM|0.00|descr|lmnop
Some kind of text 1234567891|abcd|February 14, 2008 03:58:54 AM|0.00||lmnop
Some kind of text 1234567891|abcd|February 14, 2008 03:58:54 AM|0.00||
If the sample data is what you described previously the code I posted should work. Is the data you just now posted different? You should put code tags around your data so it retains formatting.