Search For Control M characters in files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Search For Control M characters in files
# 1  
Old 10-06-2006
Search For Control M characters in files

Hi ,

I have special character control M in many of my files as below

ersNet-Telnet-3.03/Makefile.PL100644 21166 144 612 7113770214 135
77 0ustar jayusers## -*- Perl -*-^M
^M
use ExtUtils::MakeMaker qw(WriteMakefile);^M
^M
WriteMakefile(NAME => "Net::Telnet",^M
DISTNAME => "Net-Telnet",^M
VERSION_FROM => "lib/Net/Telnet.pm",^M
dist => { COMPRESS => "gzip", SUFFIX => "gz" },^M
($] >= 5.005 ?^M
(ABSTRACT => "Interact with TELNET port



Is there any script/command to find which all files have these control M characters. I tried doing a grep for ^M in my entire directories and sub-directories but it lists files which do not have ^M characters also.

Thanks in Advance
Mohammed
# 2  
Old 10-06-2006
How you are typing ^M ?

Is it using ctrl+v+m or just "^" + m

Grep should work fine with ctrl+v+m
# 3  
Old 10-06-2006
grep -R ^M * works on FC5

^M is a \r character (0x0d), try od -cx filename to find out what charachters in your file

In script you can also use od -x filename | grep 0d in a loop for each file
# 4  
Old 10-06-2006
Thanks guys..od -x command is working
# 5  
Old 10-06-2006
dos2unix (also called dos2ux) will clean up DOS files -- the (^M) thing you see at the end of every line.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Recursivley search files and replace the characters

1st_FILE.cnf Here is my sample test file . This will be replaced by . 2nd_FILE.cnf This is my 2nd test file ..This is agian a test file for purpose. variable.txt TST_FILE=1st_FILE.txt FILE_NAME=1st_FILE.txt 2ND_TST_FILE=2nd_FILE.txt REASON=test I have 2 sample config file under... (13 Replies)
Discussion started by: manas_ranjan
13 Replies

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

3. UNIX for Dummies Questions & Answers

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.. (7 Replies)
Discussion started by: prabhat.diwaker
7 Replies

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

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

6. Shell Programming and Scripting

Urgent : 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 (1 Reply)
Discussion started by: iamnoone
1 Replies

7. AIX

Randomly appearing control characters in text files

Hi, From some time, we have noticed that our ascii files have started corrupting due to the presence of some random control characters (^@, ^M, ^H, ^D). The characters appear randomly on any file after the process that creates the file finishes. If we rerun the process, the files re creates... (0 Replies)
Discussion started by: aakashahuja
0 Replies

8. Shell Programming and Scripting

Best way to search files for non-printable characters?

I need to check ftp'd incoming files for characters that are not alphanumeric,<tab>, <cr>, or <lf> characters. Each file would have 10-20,000 line with up to 3,000 characters per line. Should I use awk, sed, or grep and what would the command look like to do such a search? Thanks much to anyone... (2 Replies)
Discussion started by: jvander
2 Replies

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

10. 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
Login or Register to Ask a Question