Control characters in UNIX


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Control characters in UNIX
# 1  
Old 06-26-2014
Control characters in UNIX

Hi,

My files are showing some control characters in vi editor

^M
^@ and somtimes
^H

I removed ^M with %s/^M//g command
but how to represent ^@ and ^H
e.g. for ^M it is hold ctrl then v and m..

Please help..

I am very new to unix..
# 2  
Old 06-26-2014
Well the first thing you should ask yourself is the origin of the file: is it from a windows/DOS world, then it must be converted to remove the carriage return, either by a dos2ux or dos2unix command if it exist on your system that you hafve said nothing about or by writing a script to do the job.
This User Gave Thanks to vbe For This Post:
# 3  
Old 06-26-2014
I would expect ^M in Windows .txt files, but the ^H, ^@, and so forth are odd. Did these files come from the script utility?
This User Gave Thanks to Corona688 For This Post:
# 4  
Old 06-26-2014
ctrl+v is literal insert mode. ^ represents ctrl. so CTRL+V then CTRL+@ inserts the ^@ (which is a NUL byte)
This User Gave Thanks to neutronscott For This Post:
# 5  
Old 06-26-2014
we are running some scripts on the text files.. Scripts have been developed by dev team.. we are supposed to just run it and verify the output file.. after running the script on some set of files... output is having these characters.. anyhow dos2unix command is working.. thnks all Smilie

---------- Post updated at 10:24 PM ---------- Previous update was at 10:23 PM ----------

thnks neutronscott..

that too worked Smilie
# 6  
Old 06-26-2014
perhaps tr -d '[:cntrl:]' <oldfile >newfile to remove all control codes
This User Gave Thanks to neutronscott For This Post:
# 7  
Old 06-26-2014
Quote:
Originally Posted by neutronscott
perhaps tr -d '[:cntrl:]' <oldfile >newfile to remove all control codes
NO! Do not do this! That will remove all <newline> and <tab> characters as well as <backspace>, <carriage-return>, and other control characters that Prabhat might or might not want to remove.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Control Characters

Hallo Team, I am trying to get rid of the dollar sign. I managed to remove all the other special characters but i am struggling with this one. -bash-3.2$ cat -e missing_revenue_20141112.csv|less|head BW0522168531211141180935668@196.23.110.141$ BW092218784121114-370120610@196.23.110.141$... (4 Replies)
Discussion started by: kekanap
4 Replies

2. Shell Programming and Scripting

Request for advise on how to remove control characters in a UNIX file extracted from top command

Hi, Please excuse for posting new thread on control characters, I am facing some difficulties in removing the control character from a file extracted from top command, i am able to see control characters using more command and in vi mode, through cat control characters are not visible ... (8 Replies)
Discussion started by: karthikram
8 Replies

3. 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

4. Shell Programming and Scripting

Control Characters

Can somebody please help me with the query. ? I want a part of program of which should look for control characters in the flat file , when it finds it, displaying message that Control Characters found..! Please help me (13 Replies)
Discussion started by: iamnoone
13 Replies

5. Shell Programming and Scripting

display all possible control characters from .xml file in unix

Hi, I have a .xml file in unix. We are passing this file through a xml parser. But we are getting some control characters from input file and XML parser is failing for the control character in file.Now I am getting following error, Error at byte 243206625 of file filename_$.xml: Error... (1 Reply)
Discussion started by: fantushmayu
1 Replies

6. Shell Programming and Scripting

Hidden control characters in a Unix Text File!

Can anyone seem to know how to find out whether a UNIX text file has 'hidden' control characters? Can I view them using 'vi' by some command line options? If there are control characters in a text file which are invisible/hidden.. then how do I get rid of them? Your intelletual answers are... (6 Replies)
Discussion started by: kewl_guy
6 Replies

7. Shell Programming and Scripting

screen control characters

Hi, Can anyone help me with controlling the cursor position from a shell script. Things like moving left,right,up,down etc Anyone have any ideas? (2 Replies)
Discussion started by: ajcannon
2 Replies

8. UNIX for Dummies Questions & Answers

Remove control characters

Hi, When I do a man and save it into a file, I end up getting a lot of control characters. How can I remove them?? I tried this: /1,$ s/^H//g But I get an error saying "no previous regular expression". Can someone help me with this. Thanks, Aravind (5 Replies)
Discussion started by: aravind_mg
5 Replies

9. UNIX for Dummies Questions & Answers

getting rid of control characters

how can i get rid of the control characters , ex. ^M, ^G, in a file? thanks... (2 Replies)
Discussion started by: apalex
2 Replies

10. UNIX for Dummies Questions & Answers

printing control characters

using c-shell, does anyone know how to send control characters to the printer before the job? I need to set a printer to print in condensed mode HELP (1 Reply)
Discussion started by: mglinsk
1 Replies
Login or Register to Ask a Question