[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

"find" help

Posted on 2004-10-13
7
Medium Priority
?
205 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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…
Suggested Courses
Course of the Month18 days, 20 hours left to enroll

834 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