Replacing strang characters ^Y ^Z ^Q ^A


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replacing strang characters ^Y ^Z ^Q ^A
# 1  
Old 01-28-2010
Replacing strang characters ^Y ^Z ^Q ^A

hello frends, i am facing a problem where when i use vi to ciew my files then every line contains a special character like ^Q ^A ^Y ^Z in the very beginning. i tried to remove them using many techniques already posted in this forum but in vain. please take a sample of file when viewed in vi editor:
Code:
¤
^Y
^Y
^Y
^Z          ************************************************* ViewDirect *************************************************
^Z          ************************************************* ViewDirect *************************************************
^Z          **                                                                                                          **
^Z          **                                                                                                          **
^Z          **                                                                                                          **
^Z          **                                                                                                          **
^Z          **                                                                                                          **

now i have tried foll tech:-
1. cat filename | tr -d "\132 \131 \101 \121" > output
2. in vi: %s/ctrl-v ctrl-y//g %s/ctrl-v ctrl-z//g %s/ctrl-v ctrl-a//g %s/ctrl-v ctrl-q//g %s/ctrl-v ctrl-m//g
3. %s/control-v,Y//g
4. tr -d "[:cntrl:] < filename > output
......

please help me out of this....

Last edited by pludi; 01-28-2010 at 02:19 AM.. Reason: code tags, please...
# 2  
Old 01-28-2010
Are you using any Windows Editor to save files to unix ?
# 3  
Old 01-28-2010
no, i am getting this file from windows server via connect:direct.
# 4  
Old 01-28-2010
If you cannot trace how those characters got there in the first place (change a file transfer setting), perhaps simply deleting the first character might help?
Code:
sed 's/.//' infile > outfile

# 5  
Old 01-28-2010
thanks a lot boss.... lets hope the file will behave normally now :-)
# 6  
Old 01-28-2010
may be

Code:
do2unix infile infile

should also work
# 7  
Old 01-28-2010
actually this utility dos2unix is not installed on my server
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed replacing specific characters and control characters by escaping

sed -e "s// /g" old.txt > new.txt While I do know some control characters need to be escaped, can normal characters also be escaped and still work the same way? Basically I do not know all control characters that have a special meaning, for example, ?, ., % have a meaning and have to be escaped... (11 Replies)
Discussion started by: ijustneeda
11 Replies

2. Homework & Coursework Questions

Matching and Replacing Characters

I need to write an Unix script to report the number of SQL files in my home directory, ending with .sql . The script should, also, be checking whether there is a file with an underscore in its name. If that is the case, the underscore should be converted to a dash (‐); for example... (1 Reply)
Discussion started by: ronoz-4
1 Replies

3. Red Hat

BASH command not found strang behavior

Hi all I am relatively new to linux (specifically red hat). I have installed Fedora 13 on my machine and started playing with the terminal when i found a very strange behavior when typing a command that is not found: the terminal does not prompt me back. In other words, i am logged as root (or... (4 Replies)
Discussion started by: abohmeed
4 Replies

4. Shell Programming and Scripting

Replacing characters

Hi fellow experts, I have a question for you. Data looks like: 00877,05/13/2010,PBO,P,0000708331,518 00877,05/13/2010,PBO,P,0000708331,519 ... ... 00877,05/13/2010,PBO,P,0000708331,2103 00877,05/13/2010,PBO,P,0000708331,2104,etc,etc Basically I have to replace 518,519,2103,2104,... (4 Replies)
Discussion started by: Devski123
4 Replies

5. Shell Programming and Scripting

Replacing Characters with |

Hi All, example data.log 526569346 66815531961 09 526569346 66815531961 09 526569346 66815531961 09 526569346 66815531961 09 526569346 66815531961 09 I want like this to 526569346|66815531961|09 526569346|66815531961|09... (4 Replies)
Discussion started by: ooilinlove
4 Replies

6. Shell Programming and Scripting

Replacing Characters

Hi All, I have a file which is delimeted with the character '. i need to replace this character with the same character and also a new line. Can anyone please help me with the tr command for this. Many thanks Karan (11 Replies)
Discussion started by: karansachdeva
11 Replies

7. Shell Programming and Scripting

replacing characters

hi all I have a file that has sone spaces in start then / at last. i want to get rid of this. how to do? eg. 11414/ 49878/ 27627/ I WANT THE FILE AS 11414 49878 27627 PLEASE HELP (3 Replies)
Discussion started by: infyanurag
3 Replies

8. UNIX for Dummies Questions & Answers

replacing the characters in a file

hi i want to replace the characters between positions 2 to 30 in each line in a file how to do it suggestions welcome (2 Replies)
Discussion started by: trichyselva
2 Replies

9. UNIX for Dummies Questions & Answers

replacing characters

Hi, I have a script for replacing bad characters in filenames for f in *; do mv $f `echo $f | tr '+' '_'` done; this replaces + for _ But I need to replace all bad characters ? / % + to _ Pls how can i do this in one script ? (3 Replies)
Discussion started by: palmer18
3 Replies

10. UNIX for Dummies Questions & Answers

replacing few characters in a file

Hi All, I have huge xml file. The file contains some comment tags . I have requirement to replace comment tag with another comment tag. Say for example : file X has -- Part of the file <?xml version="1.0" encoding="ISO-2"?><translationResults jobDate="20070123 23:20:51"... (1 Reply)
Discussion started by: purnakarthik
1 Replies
Login or Register to Ask a Question