How do I list all the files in Solaris which are ^M chars in it?


 
Thread Tools Search this Thread
Operating Systems Solaris How do I list all the files in Solaris which are ^M chars in it?
# 1  
Old 10-28-2014
How do I list all the files in Solaris which are ^M chars in it?

How do I list all the files in Solaris which are ^M chars in it?

Tried the below, which didnt help
Code:
find . -type f -name "*" -exec file "{}" \; | grep -c CRLF

find . | xargs grep -l "\^M"

Thank you,
Sunil Kumar

Last edited by Don Cragun; 10-28-2014 at 02:52 AM.. Reason: Add CODE tags.
# 2  
Old 10-28-2014
In all likelihood, you aren't looking for the two character sequence ^M. Instead, you are looking for the carriage return control character that is entered on most keyboards by holding down the control key (sometimes labeled CTL or CNTRL) while pressing and releasing the m key. The following command on a Solaris 10 or 11 system should find and give you a list of the names of all regular files in and under your home directory that contain a carriage return character:
Code:
find $HOME -type f -exec /usr/xpg4/bin/grep -Fl "$(printf '\r')" '{}' +

This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 10-28-2014
Quote:
Originally Posted by msgforsunil
How do I list all the files in Solaris which are ^M chars in it?

Tried the below, which didnt help
Code:
find . -type f -name "*" -exec file "{}" \; | grep -c CRLF

find . | xargs grep -l "\^M"

Thank you,
Sunil Kumar
you can press the Ctrl key and "v" together , then press "m"
# 4  
Old 10-28-2014
Excellent, working fine. Thanks a lot for timely help!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script to split data with a delimiter having chars and special chars

Hi Team, I have a file a1.txt with data as follows. dfjakjf...asdfkasj</EnableQuotedIDs><SQL><SelectStatement modified='1' type='string'><! The delimiter string: <SelectStatement modified='1' type='string'><! dlm="<SelectStatement modified='1' type='string'><! The above command is... (7 Replies)
Discussion started by: kmanivan82
7 Replies

2. Shell Programming and Scripting

Safely Remove Files with Special Chars

Hey Guys, I'm swamped writing code for the forums: Could someone write a script or command line to safely delete files with special chars in filenames from a directory: Example: -rw-r--r-- 1 root root 148 Apr 30 23:00 ?xA?? -rw-r--r-- 1 root root 148... (8 Replies)
Discussion started by: Neo
8 Replies

3. Shell Programming and Scripting

Rename and add chars to multiple files at once

i have a little over 100 files named page1.jpg through page106.jpg. How can I rename them all to remove the page word and add 00 in front of the remaining numbers? I realize this might be multiple commands but cp page*.jpg *.jpg didn't work like I thought it would. (4 Replies)
Discussion started by: zimmerru
4 Replies

4. UNIX for Dummies Questions & Answers

list of important config files in solaris 10

Hi all, I am going to reitre one solaris 10 server soon. What are the important config files to backup in case if i want to check how this system was setup (need list in general) ? Thanks! in advance (1 Reply)
Discussion started by: lramsb4u
1 Replies

5. Shell Programming and Scripting

List files which access before 2 hours in solaris

Hi Friends, I want to the list the files in the folder which was access before 2 hours in Solaris. Thanks in advance...... (3 Replies)
Discussion started by: natraj005
3 Replies

6. UNIX for Dummies Questions & Answers

regexp: match string that contains list of chars

Hi, I'm curious about how to do a very simple thing with regular expressions that I'm unable to figure out. If I want to find out if a string contains 'a' AND 'b' AND 'c' it can be very easily done with grep: echo $STRING|grep a|grep b|grep c but, how would you do that in a single... (9 Replies)
Discussion started by: jimcanoa
9 Replies

7. Shell Programming and Scripting

How to list files in FTP prompt pagewise in solaris?

Hi, I have a solaris system with only ftp access.Need to get the list of files page wise display.. Also would like to redirect output of "ls" command to a text file in same directory. Can anyone suggest me the sollution for this? Rakesh (2 Replies)
Discussion started by: rakesh_noronha
2 Replies

8. Shell Programming and Scripting

removing non-printable chars from multiple files

How do I remove non-printable characters from all txt files and output the results to one file? I've tried the following: tr -cd '\n' < *.txt > out.txt and it gives ambiguous redirect error. How can I get it to operate on all txt files in the current directory and append the output to... (1 Reply)
Discussion started by: revax
1 Replies

9. Shell Programming and Scripting

find 4 chars on 2nd line, 44 chars over

I know this should be simple, but I've been manning sed awk grep and find and am stupidly stumped :( I'm trying to use sed (or awk, find, etc) to find 4 characters on the second line of a file.txt 44-47 characters in. I can find lots of sed things for lines, but not characters. (4 Replies)
Discussion started by: unclecameron
4 Replies

10. Shell Programming and Scripting

How to convert C source from 8bit chars to 16bit chars?

I was using the following bash command inside the emacs compile command to search C++ source code: grep -inr --include='*.h' --include='*.cpp' '"' * | sed "/include/d" | sed "/_T/d" | sed '/^ *\/\//d' | sed '/extern/d' Emacs will then position me in the correct file and at the correct line... (0 Replies)
Discussion started by: siegfried
0 Replies
Login or Register to Ask a Question