Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hi
i hav a question,suppose i hav a variable like
var="12,134,13"
now i want to put 12 134 and 13 in a seperate variable.i want to ask how to i replace delimiter and then put these nos in a seperate variable.
like var containing of 12 134 and 13
then i can iterate using for loopfor i in $ var
echo $iRegards
Abhishek
hi
my question is abt scripting.
i want to find the diffrence in two dates.
dates are in /var/log/messagesMar 27 05:48:02 abhargav sshd[1151]:
Apr 2 15:31:17 abhargav sshd[1151]:no

Hi:
The easiest way is to change the internal field separater, IFS, and use the set command to do the parsing:
var="12,134,13"
set - $(IFS=","; echo $var)
echo $1
echo $2
echo $3If you insist on using a loop, this works:
#!/bin/ksh
var="12,134,13"
OFS=$IFS
IFS=","
for i in $var
do
echo "i is: $i"
done
IFS=$OFS # restore original IFS

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |