[SunHELP] dirname command pipe failure

Jopson, Andy Andrew.Jopson at Rolls-Royce.com
Thu Jun 24 11:08:30 CDT 2004


Blown away. The simplest solution is always the best solution. I'd
appreciate it if you'd answer my other email aswell. It's here now, you can
read minds too?!!!

As you wish. I thought the same about my Masters aswell, redundant rubbish.

-----Original Message-----
From: adh at an.bradford.ma.us [mailto:adh at an.bradford.ma.us]
Sent: 24 June 2004 16:23
To: sunhelp at sunhelp.org
Subject: Re: [SunHELP] dirname command pipe failure


" From: "Jopson, Andy" <Andrew.Jopson at Rolls-Royce.com>
" 
" Does anybody know why I can't write the following code as a pipe?
" 
" 	temp=`echo $1 | tr '.' '/'`
" 	temp=`dirname $temp`
" 	echo $temp | tr '/' '.'
" 
" Like this:  echo $1 | tr '.' '/'` | dirname | tr '/' '.'
" 
" It just returns a . rather than the body of a filename (I wrote the code
to
" get whatever comes before the final dot in a filename i.e. it separates
the
" filename from it's extension). It appears that dirname (or basename for
that
" matter) doesn't function in a pipe command.

simplest answer:  use ksh.

echo ${1%.*}
does it right off.  if you want the extension alone,
echo ${1##*.}
instead.

i use ${0##*/} all the time in shell scripts to get the script name.

and could you please trim all the redundant rubbish from the tail of
your replies?  your last answer was over 200 lines!  most of which
were sig after sig after sig...
________________________________________________________________________
Andrew Hay                                  the genius nature
internet rambler                            is to see what all have seen
adh at an.bradford.ma.us                       and think what none thought
_______________________________________________
SunHELP maillist  -  SunHELP at sunhelp.org
http://www.sunhelp.org/mailman/listinfo/sunhelp


The data contained in, or attached to, this e-mail, may contain confidential
information. If you have received it in error you should notify the sender
immediately by reply e-mail, delete the message from your system and contact
+44(0)1332 242424 (the Rolls-Royce IT Security Director) if you need
assistance. Please do not copy it for any purpose, or disclose its contents
to any other person.

An e-mail response to this address may be subject to interception or
monitoring for operational reasons or for lawful business practices.

(c) 2004 Rolls-Royce Group plc

Registered office: 65 Buckingham Gate, London SW1E 6AT
Company number: 1003142. Registered in England.



More information about the SunHELP mailing list