Quote:
Originally Posted by elproducto
Thanks Guys for all the help.
For some reason the Mac OS version of sed does not like -r option and none of the Sed command worked for me I got error
Code:
sed: illegal option -- r
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
|
On OS X, you get the BSD version of
sed rather than GNU
sed, which is what most Linux distros have. The BSD version doesn't support all the options of the GNU version, and they can differ in subtle and annoying ways. (One of the great joys of the history of Unix and Linux is different implementations of core utilities.) If you want to get the GNU version, check out
MacPorts or
Fink.
And, just for fun, here's a Perl version:
Code:
echo MACIMAW1 | perl -pe 'substr($_, -3, 1, 'M')' -
(If it bothers you that the offset is -3 (three characters back starting at the end of the string), remember that Perl counts back starting from the newline: W1\n. I often forget this.)