APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

sed script echo extra argument

What is this stuff?

If this isn't exactly what you wanted, please try our Search (there's a LOT of techy and non-techy stuff here about Linux, Unix, Mac OS X and just computers in general!):

From: Bela Lubkin <belal@sco.com>
Subject: Re: misbehaving sed
Date: Wed, 24 Oct 2001 10:13:26 GMT
References: <20011024001157.A17650@jpradley.jpr.com> 

Jean-Pierre Radley wrote:

> Consider this script:
>    #!/bin/sh
>    AAA="/a/b/c"
>    BBB=`echo $AAA | /bin/sed -e 's/.*\///'`
>    echo ..$BBB..
> As expected, I run this and get
>    ..c..
> This is a simplified version of some commands in the .../bin/visionfs
> script (which I personally would have written using 'basename' and no
> pipe).
> On a customer's machine, I just installed
>    rs506a
>    sse071
>    sse072c
>    sse073
>    CSSA-2001-SCO.1
>    CSSA-2001-SCO.10
>    CSSA-2001-SCO.12
>    CSSA-2001-SCO.17
>    CSSA-2001-SCO.20
> My script, on that machine errs and writes out:
>    ..c ..
> [The visionfs script barfs:
>    Unable to open message file:
>    /usr/vision/visionfs/_inst/en_US /visionfs
> failing because of that trailing space introduced by the sed command.]
> NB: sed isn't changed by any of the mentioned patches, and both the
> customer's machine and mine have the same libc.so.1 file out of rs506a.

The problem is not in sed.  This script will produce the same failure:

  BBB=`echo c`
  echo ..$BBB..

The problem is in fact in /bin/sh, which you installed from
CSSA-2001-SCO.24 (which you didn't mention).

The CSSA-2001-SCO.24 version of /bin/sh, /sbin/sh and
/usr/lib/scosh/utilbin/oash has a bug in its built-in "echo" command; it
sees one more argument than you specified, and thus outputs an extra
space (to separate the last real argument from the false one).  The
content of this false extra argument are always empty, so you just get
an extra space.

CSSA-2001-SCO.24 will be updated or replaced (I don't know what the
current policy is) to fix this.


Got something to add? Send me email.

(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> -> sed script echo extra argument ––>Re: misbehavingsed

1 comment

Increase ad revenue 50-250% with Ezoic

Sat Aug 21 20:42:58 2010: 8925   Sathish


I have a script like below
#! /bin/ksh
echo $1
echo $2

I saved the program as test.ksh, when i run this from the command line like
test.ksh abc def

Its not echoing the parameters passed where as if i run like
ksh test.ksh abc def
its working fine-i just wnat to know hwy the option 1 is not running
Your help is appraeciated

Kerio Samepage

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us