Home » Infrastructure » Unix » Korn Shell- Trim spaces
Korn Shell- Trim spaces [message #148361] Wed, 23 November 2005 15:57 Go to next message
mchittib
Messages: 87
Registered: September 2005
Member
Can someone tell me How to trim spaces leading and trailing for a variable.

Thanks In advance
Re: Korn Shell- Trim spaces [message #148537 is a reply to message #148361] Thu, 24 November 2005 18:00 Go to previous messageGo to next message
rleishman
Messages: 3728
Registered: October 2005
Location: Melbourne, Australia
Senior Member
Heres one way

a=`echo $a | sed -e 's/^ *//' -e 's/ *$//'`


There is a more elegant way using typeset -L if the variable is a fixed length.
_____________
Ross Leishman
Re: Korn Shell- Trim spaces [message #148861 is a reply to message #148537] Mon, 28 November 2005 14:30 Go to previous message
mchittib
Messages: 87
Registered: September 2005
Member
Thanks a lot.
That works.
Previous Topic: runInstaller : cannot execute ( Solaris 10 X-86 and Oracle 9i2 )
Next Topic: How to call sqlplus from shell script by hide password
Goto Forum:
  


Current Time: Mon Nov 25 10:47:15 CST 2024