Bad character in output file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bad character in output file
# 1  
Old 01-11-2012
Network Bad character in output file

Hi All,

I am facing some problems with bad characters in my file.For example-
Code:
00000000509 TCI DEVOFFERS= 1

Now I want to remove all bad characters and replace with *.
Please suggest some solution.

Along with that How to mention a range of ASCII values in TR command to replace?

Say I want to replace ASCII value 32 -38(Dec) with Asterisk(*), how to perform with TR command in UNIX.


Please help.


Moderator's Comments:
Mod Comment Use code tags, thanks.

Last edited by zaxxon; 01-11-2012 at 09:22 AM.. Reason: code tags
# 2  
Old 01-11-2012
try sed
Code:
sed 's/[ #!"$%&]//g'  inputfile > newfile

The [ ] thing is called a "character class" in regular expressions
# 3  
Old 01-11-2012
The behaviour of the "tr" command is Operating System dependent.

What Operating System and version you you have? What Shell are you using?



Btw. The equals sign in your example not in the ASCII range you define.
When working with "tr" to remove "bad" characters it is much easier if you can define the exact range of "good" characters.

Last edited by methyl; 01-11-2012 at 10:15 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove newline character if it is the only character in the entire file.?

I have a file which comes every day and the file data look's as below. Vi abc.txt a|b|c|d\n a|g|h|j\n Some times we receive the file with only a new line character in the file like vi abc.txt \n (8 Replies)
Discussion started by: rak Kundra
8 Replies

2. Shell Programming and Scripting

ksh - Get last character from string - Bad Substitution error

I want to get the last character from my machine name using the following code, the default shell is bash, the script runs in ksh. I get 'bad' substitution error on running the script, but works fine if run using dot and space. Why? $ echo $0 bash $ cat -n myenv.sh 1 ... (8 Replies)
Discussion started by: ysrini
8 Replies

3. Shell Programming and Scripting

Shell script remove bad character

I was curious to know how to write into my shell script to remove a character. The character I want to remove is  within a .html file. (18 Replies)
Discussion started by: graphicsman
18 Replies

4. Shell Programming and Scripting

File character adjustment based on specific character

i have a reqirement to adjust the data in a file based on a perticular character the sample data is as below 483PDEAN CORRIGAN 52304037528955WAGES 50000 89BP ABCD MASTER352 5434604223735428 4200 58BP SOUTHERN WA848 ... (1 Reply)
Discussion started by: pema.yozer
1 Replies

5. Shell Programming and Scripting

read the text file and print the content character by character..

hello all i request you to give the solution for the following problem.. I want read the text file.and print the contents character by character..like if the text file contains google means..i want to print g go goo goog googl google like this Using unix Shell scripting... without using... (1 Reply)
Discussion started by: samupnl
1 Replies

6. Shell Programming and Scripting

Deleting all characters from 350th character to 450th character from the log file

Hi All, I have a big log file i want to delete all characters (between 350th to 450th characters) starting at 350th character position to 450th character position. please advice or sample code. (6 Replies)
Discussion started by: rajeshorpu
6 Replies

7. Shell Programming and Scripting

read in a file character by character - replace any unknown ASCII characters with spa

Can someone help me to write a script / command to read in a file, character by character, replace any unknown ASCII characters with space. then write out the file to a new filename/ Thanks! (1 Reply)
Discussion started by: raghav525
1 Replies

8. Shell Programming and Scripting

Fileserver in Perl via xinetd - bad XML output

Hello there, I hope I took the right forum... I never worked with Perl, but now I have to get a simple fileserver running. The goal is to deliver an XML file (it's part of a new security model in the Flashplayer, see Adobe - Developer Center : Setting up a socket policy file server for more... (9 Replies)
Discussion started by: blemmo
9 Replies

9. Shell Programming and Scripting

Script to search a bad record in a file then put the record in the bad file

I need to write a script that can find a bad record (for example: there is date field colom but value provided in the file for this field is N/A) then script shoud searches this pattern and then insert the whole record into the bad file. Example: File1 Name designation dateOfJoining... (2 Replies)
Discussion started by: shilendrajadon
2 Replies

10. UNIX for Advanced & Expert Users

Script to search a bad record in a file then put the record in the bad file

I need to write a script that can find a bad record (for example: there is date field colom but value provided in the file for this field is N/A) then script shoud searches this pattern and then insert the whole record into the bad file. Example: File1 Name designation dateOfJoining... (1 Reply)
Discussion started by: shilendrajadon
1 Replies
Login or Register to Ask a Question