![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Find/replace to new file: ksh -> perl | McLan | Shell Programming and Scripting | 1 | 05-16-2008 04:14 AM |
| read space filled file and replace text at specific position | COD | Shell Programming and Scripting | 6 | 04-21-2008 06:40 AM |
| replace the last delimiter | jisha | Shell Programming and Scripting | 4 | 01-28-2008 06:26 AM |
| replace delimiter : with '\001' in unix data file | spandu | Shell Programming and Scripting | 4 | 04-25-2006 09:51 AM |
| field delimiter with a space or more | uphamtn | UNIX for Dummies Questions & Answers | 3 | 05-15-2003 05:22 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Code:
open(FH_TMP,"<","$chk_file");
open(OUT,">>",tmpfile);
while (my $line = <FH_TMP>)
{
$line =~ s/ {2,}/|/g;
print OUT $line;
}
close(FH_TMP);
close(OUT);
Code:
@ARGV = ($chk_file);
$^I = '.bak';
while (<>){
s/ {2,}/|/g;
print;
}
|
|
||||
|
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):
Code:
{
local @ARGV = ($chk_file);
local $^I = '.bak';
while (<>){
s/ {2,}/|/g;
print;
}
}
|
|
||||
|
Hi,
This is the sample data i have ... 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|| Thanks! Last edited by meghana; 02-19-2008 at 06:35 PM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|