![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| 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 | Shell Programming and Scripting | 5 | 02-01-2008 06:45 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#8
|
|||
|
|||
|
Thanks Perderabo...
I am using AIX, version 4. I want to keep the special characters like double quotes("), spaces, +, - etc. retained. When I used : tr -c '[:print:][:cntrl:]' ' ' < input_file > output_file all these characters also got removed. (Anything to do with [:print:] ?) Also, [:alnum:] didn't change the file itself : tr -c '[:alnum:]' ' ' < subs.bak > sub.err Have got tired of using so many options. Have to resolve this issue as soon as possible. Clients jumping on me. Thanks Kanu |
| Forum Sponsor | ||
|
|
|
#9
|
|||
|
|||
|
Are there some more options? Thanks in advance..
-Kanu |
|
#10
|
|||
|
|||
|
If the list of characters to be removed is finite have them in the file "unwanted_chars"
and try this code Code:
#! /opt/third-party/bin/perl
open(FILE, "<", "unwanted_chars");
while(<FILE>) {
chomp;
$fileHash{$_} = 0;
}
close(FILE);
open(FILE, "<", $ARGV[0]) || die ("unable to open <$!>\n");
while( read(FILE, $data, 1) == 1 ) {
$ordVal = ord($data);
print $data if( !defined($fileHash{$ordVal}) );
}
close(FILE);
exit 0
|
|
#11
|
|||
|
|||
|
Thanks Madhan! The list of characters is not finite. These are some dump character which creep into the records. I believe it would be helpful if you see my attached example.
Anyways, the logic is good. Atleast I can remove some of the characters which I know. Thanks Kanu |
|
#12
|
|||
|
|||
|
Quote:
Actually these are valid characters but not for all the character sets. It might be that they are valid and due to the encoding character set of the terminal it might turn out to be junk or unwanted characters. Better take a hex dump of the file and verify its needed or not |
|
#13
|
|||
|
|||
|
I dont know why, but I always wanted to get this answer.
I always doubted this. I think at the place of 'space' some dump characters are coming. How can I check the encoding character set of the terminal? Can I change it too? I want to resolve the root cause, so that we can avoid using some more scripts. Thanks Kanu |
|
#14
|
|||
|
|||
|
This is what I got :
#echo $LANG En_US Helpful? |
|||
| Google The UNIX and Linux Forums |