#!/bin/bash
# Split the command line argument on the colon character.
SaveIFS=$IFS
IFS=:
declare -a Array=($*)
IFS=SaveIFS
echo Array[0]=${Array[0]}
echo Array[1]=${Array[1]}
echo Array[2]=${Array[2]}
echo Array[3]=${Array[3]}
Unga wrote:
Hi all
How to use bash and IFS to split a
Please allow me a sidenote:
On Fri, 5 Sep 2008 09:38:29 -0700 (PDT), Jim Hertzler [EMAIL PROTECTED] wrote:
#!/bin/bash
^
Isn't compatible to FreeBSD, I think, because BASH is an additional
package and the bash binary will be installed into /usr/local/bin/bash;
unless you're not using
Go to:
http://www.linuxquestions.org/questions/programming-9/bash-shell-script-split-array-383848/?posted=1#post3270996
And see:
IP=1.2.3.4; IP=(${IP//./ }); Rev=${IP[3]}.${IP[2]}.${IP[1]}.${IP[0]}
Unga wrote:
Hi all
How to use bash and IFS to split a string?
eg.
$string =
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Unga
Sent: 25 August 2008 10:40
To: freebsd-questions@freebsd.org
Subject: string split, bash and IFS
How to use bash and IFS to split a string?
eg.
$string = Name:Surname:10
IFS=:
echo
--- On Mon, 8/25/08, Barry Byrne [EMAIL PROTECTED] wrote:
From: Barry Byrne [EMAIL PROTECTED]
Subject: RE: string split, bash and IFS
To: [EMAIL PROTECTED], freebsd-questions@freebsd.org
Date: Monday, August 25, 2008, 7:54 PM
-Original Message-
From: [EMAIL PROTECTED]
[mailto
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Unga
Sent: 25 August 2008 15:11
To: Barry Byrne
Cc: freebsd-questions@freebsd.org
Subject: RE: string split, bash and IFS
--- On Mon, 8/25/08, Barry Byrne [EMAIL PROTECTED] wrote:
From