Re: Simple sed replacement tool

From: Kevin Collins (spamtotrash_at_toomuchfiction.com)
Date: 05/14/04


Date: Thu, 13 May 2004 23:50:40 GMT

In article <pan.2004.05.13.23.33.58.210051@dont.spam.me>, Bob wrote:
> On Thu, 13 May 2004 23:08:24 +0000, Kevin Collins wrote:
>
>
>>
>> Some people in this group seem to have knee-jerk reaction when Perl is
>> mentioned, but this is still the best thing since sliced bread if you have
>> perl (no shell script required):
>>
>> $ perl -pi -e 's/string1/string2/g' *
>>
>> Which does the substitution inline and doesn't require the user to deal
>> with redirecting or temp files... In addition, it can open you up to the
>> wonderful world of Perl one-liners, which can be just as useful (if not
>> more so) than any sed/awk/grep one-liners.
>>
>
> You are right. But, I often need to write scripts for small systems where
> bash is the most sophisticated tool available. Sometiems I even need to
> temporarily install my own statically linked bash.

Yep, its the old portability issue :) Some people are much more hard-core on
being portable and it IS good to know the alternatives for those times, but if
you know your environment then YOU are the best judge.

For example, in my environment, there are approximately 100 servers, with 90%
being HP-UX and the rest being RedHat Linux. If I write a shell script, its
written in ksh and using all of the ksh syntax and semantics because I don't
NEED to write it at a Bourne shell level - I have ksh88 on HP-UX and pdksh on
Linux, and I know (for the most part) the ways around the differences in the
utilities.

Now, if I were writing scripts for (say) a software vendor, where they had to
run on any platform, then I would write in strict Bourne shell style and be
militant about portability (like Chris F.A.J.!).

Kevin

ps - Chris, that is a compliment :)



Relevant Pages

  • Re: $_GET[var] works, but $var doesnt
    ... "Chris Hope" schreef in bericht ... > Marian Heddesheimer wrote: ... > that it ensures greater portability of your scripts. ...
    (comp.lang.php)
  • Re: function definition syntax
    ... :>:>: And even easier to write portable POSIX scripts. ... I said POSIX scripts, not sh scripts. ... : portability. ... :> sample output of echo to determine which functionality is used - ...
    (comp.unix.shell)
  • Re: Read command and trailing spaces
    ... more than 90% of the time the Bourne shell is perfectly ... > If you want to write portable scripts, ... wouldn't count on much beyond basic POSIX features being fully ... (I installed bash for my ...
    (comp.unix.shell)
  • Re: Bourne Shell Port Available
    ... > boxes trying to avoid the Bourne shell. ... processing legacy scripts and for testing the portability of shell ... modern shells are a moving target for the script programmer - not ... obligation to the POSIX standard requires them to fix non-conforming ...
    (comp.unix.shell)
  • Re: Apparently, csh programming is considered harmful.
    ... Can someone please explain why bash sucks? ... boot scripts without bashisms. ... I don't understand why everyone insists on POSIX compliance for portability ... with shell scripting. ...
    (freebsd-questions)