[ale] I am an idiot
Wandered Inn
esoteric at denali.atlnet.com
Tue Jun 26 17:56:12 EDT 2001
> Chris Fowler wrote:
>
> #!/bin/ksh
> #
> STRING="hello|goodbye"
>
> VAR1=`echo $STRING | cut -d'\|' -f1`
> VAR2=`echo $STRING | cut -d'\|' -f2`
>
> #END
Noticed you used ksh, this might be a bit faster:
#!/bin/ksh
var="hello|world"
var1=${var#*\|}
var2=${var%\|*}
You could probably rid yourself of having to escape the delimiter if you
used something else. That effort is left for your exercise. :)
>
> -----Original Message-----
> From: Jason Lynn [mailto:jason_lynn_ at hotmail.com]
> Sent: Tuesday, June 26, 2001 5:03 PM
> To: ale at ale.org
> Subject: [ale] I am an idiot
>
> Now that that's out of the way... here's my problem.
>
> #!/bin/ksh
> #
> echo AARGH!
> exit 0
>
> I need some way to do some basic string manipulation that works both
> for
> Linux and Solaris (out of the box). I basically need to take a string
> like
> "hello|goodbye" and split that string into two components, hello and
> goodbye
> (assign them to shell variables, etc.) by a delimeter such as '|'. I
> thought everything was going well when I used expr to do just that.
> No
> problems in Linux. It appears, though, that functions like substr,
> length,
> etc are NOT supported in sparc Solaris. So I looked into awk and sed
> (for
> the first time), which only served to piss me off even more. Can
> anyone
> help me with this one?
>
> Thanks in advance,
> Jason
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com
>
> --
> To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in
> message body.
--
Until later: Geoffrey esoteric at denali.atlnet.com
"Great spirits have always found violent opposition from mediocre minds.
The latter cannot understand it when a man does not thoughtlessly submit
to hereditary prejudices but honestly and courageously uses his
intelligence." - Albert Einstein
--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.
More information about the Ale
mailing list