![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| removing pattern which is spread in multiple lines | sabyasm | Shell Programming and Scripting | 2 | 05-13-2008 02:19 AM |
| Removing certain text from multiple filenames | Djaunl | UNIX for Dummies Questions & Answers | 6 | 01-15-2008 02:52 PM |
| removing old files except configuration files and folders | jamcalicut | Shell Programming and Scripting | 1 | 11-09-2007 01:34 PM |
| Please Help. Need Help searching for multiple stings in a file and removing them. | mjs3221 | UNIX for Advanced & Expert Users | 2 | 08-19-2006 03:28 AM |
| Removing user from multiple groups via command line | jquizon62 | SUN Solaris | 1 | 10-28-2004 09:56 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Removing M^ from multiple files
to do this i usually type dos2unix <file> -o <file>
and this will remove the M^ from the end of each file. well i have over 100 files that someone copied that i need. how do i remove the M^. i saw a perl script but i am not familiar with .pl at all really |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Perl not needed.
Try it in a test area first..... Code:
#!/bin/sh
find directory -type f | while read N
do
if dos2unix "$N" -o "$N".tmp
then
mv "$N".tmp "$N"
fi
done
|
|
#3
|
|||
|
|||
|
sorry i just reread my post. i meant within the file there is the ^M not on the extensions.
|
|
#4
|
|||
|
|||
|
sorry but it cannot find when i run the command
find: cannot open directory: No such file or directory |
|
#5
|
|||
|
|||
|
for f
do mv $f ${f}~ && tr -d '\015\032' <${f}~ >$f rm ${f}~ done <script> <file> this worked for me thanks |
|
#6
|
|||
|
|||
|
Quote:
That is because "directory" is supposed to be replaced by the directory you want to make the changes in. As a general idea, if you are offered a script that you don't understand what it's doing, don't run it, ask what a part of it is doing. Otherwise people could tell you to run all kinds of rubbish. |
|
#7
|
|||
|
|||
|
Just to pass on snippets, here's what I use:
perl -pe 's/\015\012/\n/g' - dos to unix -- just pipe through it perl -pe 's/\n/\015\012/g' - unix to dos -- just pipe through it cat filename |perl -pe 's/\015\012/\n/g' > filename.without.ctrl.m dos2unix works well, but isn't on all systems. I now use this perl. |
|||
| Google The UNIX and Linux Forums |