The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Duplicates to be removed prvnrk Shell Programming and Scripting 6 07-10-2008 10:06 AM
a way to tell what was removed after rm -rf ? thosch UNIX for Dummies Questions & Answers 4 06-30-2008 02:20 AM
after init all /tmp file has been removed yesthomas SUN Solaris 5 12-06-2005 03:48 AM
directories are not getting removed slavam Shell Programming and Scripting 6 11-17-2005 05:26 PM
Will Old Files Be Removed sunsation UNIX for Dummies Questions & Answers 5 06-26-2005 09:24 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 09-02-2008
otheus's Avatar
Moderator ala Mode
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 605
Quote:
Originally Posted by telecomics View Post
I used the following to remove ^M in all files - I guess i did it in haste

find / -name "*" | xargs perl -p -i -e 's/^M//g' *
Despite what bufoonix wrote, you can do what you are trying to do... To do it right, however, you must replace the \015 character with another character, such as a space (\020).

The thing is, you really don't want to replace all instances of \015, because that might represent code or some piece of instruction, initialization data, etc. You have to be more selective. Try something like this (and test it !!)

Code:
perl -p -i -e 's/\015(\012)/ $1/gs' *
At least this way you get \015s coupled before a newline. The problem is trickier, however, since in some compilers, something like, "strchr(string, crnl)", the "crnl" is actually "\r\n" and the strchr library handles that as a special case. I'm not sure what will happen if you substitute a space-newline in there!

I can imagine other sorts of headaches you might encounter.
Reply With Quote
Forum Sponsor
  #9  
Old 09-02-2008
drl's Avatar
drl drl is offline
Registered User
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 556
Hi.
Quote:
Originally Posted by telecomics View Post
...
find / -name "*" | xargs perl -p -i -e 's/^M//g' *
It changed all my LIBRABRIES since i used -- perl -p -i -e 's/^M//g' *
I suspect that because the OP began at /, there were also executables that were changed.

A filter to eliminate non-text items would be the first step I would suggest. The command file makes good guesses about the content of files, but it varies among systems, so one would need to do a few experiments first.

Running commands and scripts with an echo in front of the command that will do the real work is often a good idea. One then can see what will get changed, and the process can be fine-turned until it meets the requirements.

This was a good learning experience -- tough, but good -- and I think many of us have had that happen at least once. It underlines the usefulness of backups. Currently I do a lot of work in virtual machines, and the snapshot is very easy, not dissimilar to what buffoonix outlined for LVM volumes. I do that for almost every update that is made available. There was a number of weeks when GNU/Debian testing updates made a mess of fonts and the desktop. I did snapshots and restored until they got it straightened out ... cheers, drl
Reply With Quote
  #10  
Old 09-02-2008
Registered User
 

Join Date: Sep 2008
Posts: 6
Thanks for all your replies .

Just to mention, Ctrl V and then Ctrl M was used to replace the characters in the executed command which changed most of my jar and lib files.

My Sysadmin can backup the filesystem using /usr/openv/netbackup/bin/bp command

Is it better to replace just the libraries that were changed on that mountpoint (they are too many including the ./java/jre/lib ) or the entire mountpoint since my vignette application is "installed" on Solaris at /apps dir , would replacing the entire /appl directory be sensible ?

Another observation - No binary files were changed - signifying they dont have any such control chars.

Last edited by telecomics; 09-02-2008 at 12:11 PM.
Reply With Quote
  #11  
Old 09-02-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
Restore as much as you can and start over, would be my advice.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:57 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0