Welcome, Guest
Username Password: Remember me

Remove Control ^M from files
(1 viewing) (1) Guest
Perl Script
  • Page:
  • 1

TOPIC: Remove Control ^M from files

Remove Control ^M from files 1 year, 10 months ago #263

  • tpatil
  • OFFLINE
  • Junior Boarder
  • Posts: 27
  • Points: 5105
  • Karma: 0
  • Honor Medal 2009
Single file method
 
perl -pi -e "s/\r//" filename.txt
 


Multiple File Method
find . -type f -exec perl -pi -e "s/\r//" {} \;
 

Re:Remove Control ^M from files 1 year, 10 months ago #265

  • rajeshkumar
  • OFFLINE
  • Moderator
  • I love software configuration management
  • Posts: 370
  • Points: 44562
  • Karma: 4
  • Honor Medal 2009
I used to do in shell using following command

> 1,$s/^M//g

Correct me if I am wrong
Regards,
Rajesh Kumar
Build and Release Engineer
My Blog: community.scmgalaxy.com/pg/profile/rajeshkumar

Re:Remove Control ^M from files 1 year, 10 months ago #266

  • tpatil
  • OFFLINE
  • Junior Boarder
  • Posts: 27
  • Points: 5105
  • Karma: 0
  • Honor Medal 2009
Yes, this is also correct command if you want to remove ^M from single file in VI edit mode.
  • Page:
  • 1
Time to create page: 0.84 seconds

     
    
Home Forum