![]() |
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 |
| Replacing the Spaces | Amey Joshi | UNIX for Dummies Questions & Answers | 3 | 11-11-2008 11:15 PM |
| need help in replacing spaces in a file | sais | Shell Programming and Scripting | 7 | 10-06-2008 09:24 AM |
| Replacing character in file with null value | HLee1981 | Shell Programming and Scripting | 18 | 07-18-2006 01:33 PM |
| Handling null input... | DrRo183 | Shell Programming and Scripting | 2 | 04-11-2006 01:32 AM |
| finding & replacing blank rows/spaces in a file | Gerry405 | SUN Solaris | 2 | 07-21-2005 04:49 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
replacing spaces with null or 0 in the input file
hi
i have records in my input file like this aaa|1234||2bc||rahul|tamilnadu bba|2234||b4c||bajaj|tamilnadu what i am expecting is in between two pipes if there is no character it should be replaced with null or 0 so my file will look like this aaa|1234|null|2bc|0|rahul|tamilnadu bba|2234|null|b4c|0|bajaj|tamilnadu how to do it can anyone explain thanks in advance |
|
||||
|
Code:
#! /usr/bin/perl
open FH,"<a.txt";
while(<FH>){
my @tmp=split("[|]",$_);
map{$_=$_||"null"} @tmp;
print join "|",@tmp;
}
|
| Sponsored Links | ||
|
|