![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Removing a file name (-T-G1) | bobo | UNIX for Dummies Questions & Answers | 3 | 03-05-2008 11:26 AM |
| Need Help Removing a File | GTRocker8824 | UNIX for Dummies Questions & Answers | 1 | 02-15-2008 12:04 AM |
| Spurious line feeds | ajcannon | Shell Programming and Scripting | 2 | 10-29-2007 07:24 AM |
| removing a line from a file and then placing into another file | iago | UNIX for Dummies Questions & Answers | 1 | 09-09-2007 02:46 AM |
| removing file | vbaskar | UNIX for Advanced & Expert Users | 5 | 02-12-2002 04:43 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Morning,
Hopefully someone can help an newbie! I have been getting a number of file corruptions with Rogue "Control M" charactors [ carriage return ]. The effect is: Should be aaaa bbbb cccc dddd (4 lines) But getting aaaa bb<Ctl M> bb ccccc dddd (5 lines) I am having to correct this manually using vi... Anyone know a way to do this in a script? Effectively I want to delete any occurrances of the string "^M\n" I can't use tr as tr -d "^M" leaves two lines. tr -d "^M\n" also deletes the genuine "\n" at end of line. Any suggestions? sed? The problem with manuals is that you need to know what to look up! |
|
||||
|
Sorry I relied too much on your title and assumed it was a single file.
Try playing with this: Code:
for fl in *.php; do mv $fl $fl.old sed 's/FINDSTRING/REPLACESTRING/g' $fl.old > $fl #rm -f $fl.old done Code:
for i in `find ./ -type f -exec grep -l "yourstringhere" {} \;`
do
# use our sed rules to make changes. put them in a temp file
sed -f ./sedlist $i > $i.tmp
# this is optional. make a back up to be safe.
#cp $i $i.sedbak
# move the new temp file over the original
mv $i.tmp $i
done
Of course, change the values to suit your needs. |
|
||||
|
the problem is that the
corruption inserts a <Ctl M> charactor and throws a line. Hence instead of bbbb we get : bb<CtlM> bb By simply substituting <Ctl M> with '' I get bb bb when I want bbbb In vi I have to use "J" to concatinate the two lines after subsituting <Ctl M> for '' Hence I think I need to substitute the string ^M\n with '' but I can't get this to work |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|