The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 05-26-2009
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,554
if you have Python

Code:
#!/usr/bin/env python
import string
FROM="12345"
TO="67890"
table=string.maketrans(FROM,TO)
for line in open("file"):
    line=line.strip().split(",")
    line[1]=line[1][:4].translate(table) + ''.join(line[1][4:])
    print ','.join(line)

output

Code:
# python test.py
"1234,0678,0987,12345667,000000976655,+1234,013994878356"
"0987,78967,11243554,0000887651,1234567,09876,1234455"
"0987675,6778443,797784784784,09866545,+232322,097865"