Solved

"find" help

Posted on 2004-10-13
7
198 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

733 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