The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Removing certain characters in a file bombcan Shell Programming and Scripting 2 04-25-2008 12:53 PM
Replacing characters in csv file finwhiz UNIX for Dummies Questions & Answers 1 03-31-2008 02:25 AM
Invalid Characters in the file. kanu_pathak UNIX for Dummies Questions & Answers 15 02-04-2008 04:10 AM
how to see special characters in a file using vi jingi1234 UNIX for Dummies Questions & Answers 6 10-19-2005 08:57 AM
grepping the first 3 characters from a file rachael UNIX for Dummies Questions & Answers 2 10-15-2001 11:33 AM

Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-31-2008
Registered User
 

Join Date: Jan 2008
Location: India
Posts: 32
Invalid Characters in the file.

I am working on AIX. We ftp files to a database. The flat files are having thousands of records and each record is having some 50 to 60 characters(there are fields having certain character length). In addition to some valid ascii characters some invalid characters like Å, å, Ä, ä or pipes creep in which datawarehouse rejects to load in.
Example: AcuM-^?a 051706 ;
above is a field in the record which is having special characters like -,^ and ? , which should not have been there.

The record separator is a new line and there is no field seperator.

How can I remove these invalid or special characters to creep in the records?
Please help me to find the logic in the shell sripting..
Forum Sponsor
  #2 (permalink)  
Old 01-31-2008
Registered User
 

Join Date: Jan 2008
Location: India
Posts: 32
After removing the invalid characters I want to add the space at the same place.
Means, I have to replace the invalid character with a space.

Thanks in advance...
  #3 (permalink)  
Old 01-31-2008
Registered User
 

Join Date: Jan 2007
Location: Boston, USA
Posts: 16
Check with perl

Hi Kanu,

Please try the below.
Note: The change will be made to the input file directly.

Code:
perl -pi -e 's/-/ /g'  <file >
perl -pi -e 's/^/ /g'  <file >
Once you have the list of the strange characters, you can proceed like this.

==========
Thanks,
Karthikeyan.
==========
  #4 (permalink)  
Old 02-01-2008
Registered User
 

Join Date: Jan 2008
Location: India
Posts: 32
Question

Hi Karthik,

Thanks for the reply.
I do not have any particular list of invalid characters, the characters come up randomly. For example : ~, æ, £, Ç, Ä etc. Also I am not aware with perl, so clueless.
Can you plz help me in some other ways...!

-Kanu
  #5 (permalink)  
Old 02-01-2008
Registered User
 

Join Date: Mar 2007
Location: Chennai
Posts: 222
I guess your query was answered in your earlier post on the same topic Invalid Characters in the file.

Please avoid duplicating the post

Thanks
Nagarajan G
  #6 (permalink)  
Old 02-01-2008
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,356
I will close this duplicate thread. Please read our rules. Double posting is not allowed.
Google UNIX.COM
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:22 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0