TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [TCLUG:1906] Shell Script Question -
I'm sitting here banging my head about tr, but for script usage, you can
easily use the perl functionality to mimic tr. I may have hosed up
something, but you get the idea. It's been a while since I've done
extensive perl.
*** dos2unix.pl ***************
#!/usr/bin/perl
while ($line = <STDIN>) {
$line =~ tr/\r//;
print $line;
}
*******************************
% cat myfile.dos | dos2unix.pl > newfile.unix
Regular tr looks something like this:
% tr ab ba < infile > outfile
changes infile contents of "bad" to outfile contents of "abd". I can't
remember how to do control characters though.
Luke Francl wrote:
...
But what I would like to do is write a shell script to remove the ^M
from every file in a directory. Brad says tr can be used for this, but I
have no experience with this tool...what parameters would I need to give
it in order to make this work?