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

sed script echo extra argument

© December 2004 (various authors)

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

Inexpensive and informative Apple related e-books:

El Capitan: A Take Control Crash Course

Take control of Apple TV, Second Edition

Take Control of Pages

Photos for Mac: A Take Control Crash Course

Take Control of iCloud

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


Printer Friendly Version

Have you tried Searching this site?

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

Printer Friendly Version

It's more fun to be a pirate than to join the navy. (Steve Jobs)

Linux posts

Troubleshooting posts

This post tagged:



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode

SCO Unix Sales, Support, & Service

Phone:  707-SCO-UNIX (707-726-8649Toll Free: 833-SCO-UNIX (833-726-8649)