|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Parsing string variables
Hi!
I want to know if there is a way for me to parse a string variable containing a comma-separated list. Then using a loop, remove each element from the list alongwith the comma separator until the string variable becomes empty. Thank you. Shakeel |
|
#2
|
|||
|
|||
|
In ksh,
Code:
list="one,two,3333 3333,four,five"
echo "$list" | tr '[,]' '[\n]' | while read item
echo "$item"
done
|
|
#3
|
|||
|
|||
|
Sounds like homework to me.
Here is a start: Code:
var="a,big,bus full of,people,went,home on sunday"
echo "$var"| awk '{z=split($0,flds,",")
for(i=1;i<=z;i++)
print flds[i]}'
var=""
|
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Parsing string variables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|