Solved

"find" help

Posted on 2004-10-13
7
194 Views
Last Modified: 2013-11-13
Can someone please show me how to use the find command to search a directory and all subdirectories (all files) and replace all instances of \r\n with \r?  I've got some windows text files that I need to convert to unix style.  Any other method to easily do this would also be acceptable.

Thanks
0
Comment
Question by:dirtdart
  • 4
  • 3
7 Comments
 
LVL 11

Expert Comment

by:avizit
Comment Utility
there is a better way to do this if your system has it ..

the command to use is "dos2unix"  

try

find . -type f | xargs dos2unix

0
 
LVL 5

Author Comment

by:dirtdart
Comment Utility
I'm running Slack 10 and it doesn't look like it's installed.  Is this something I can download?
0
 
LVL 11

Expert Comment

by:avizit
Comment Utility
be warned not that you should do that only for txt files

so maybe you can modify it to


find . -type f -name "*.txt" | xargs dos2unix

if all your files have extension .txt ,
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 5

Author Comment

by:dirtdart
Comment Utility
Thanks.  I just found a download site.  They're all php files, so it should work the same.  Let me give it a try when I get my files transferred and if it works, I'll come back and reward the points.
0
 
LVL 11

Expert Comment

by:avizit
Comment Utility
you can get dos2unix sources from
http://www.megaloman.com/~hany/software/hd2u/

or if you can install using rpm you can get the dos2unix rpm from rpmfind.net
0
 
LVL 11

Accepted Solution

by:
avizit earned 500 total points
Comment Utility
getting "dos2unix" is preferable cos the other solutions ( check http://mikeage.net/content/tips/linux/dos2unix.php )
creates a new file , so you have to save that as tempfile and then move the tempfile over the original file . hence your script becomes messy .

dos2unix and unix2dos works on the same file ..hence better IMHO
0
 
LVL 5

Author Comment

by:dirtdart
Comment Utility
Worked like a charm!  Thanks for the help.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Among others, I monitor the Windows Installer zone and Installer zone. I find that many of the questions could be answered much more quickly if a Windows Installer verbose log were submitted with the question.   However, I do not always have t…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now