Solved

"find" help

Posted on 2004-10-13
7
196 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
ID: 12304835
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
ID: 12304845
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
ID: 12304847
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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 5

Author Comment

by:dirtdart
ID: 12304856
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
ID: 12304860
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
ID: 12304872
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
ID: 12306908
Worked like a charm!  Thanks for the help.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

810 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