Reputation: 25
Hey Guys i want to split a string into two seperate, e.g. resolution=1024x786 to width=1024 and height=786. To do this, i found that code:
set -- "$resolution"
IFS="x"; declare -a coordinates=($*)
Source But now are all my Variables that contain an "x" in any position split there. How can use this "IFS" just for my $resolution?
Thanks for your Help :)
Upvotes: 0
Views: 99
Reputation: 241861
One solution
IFS=x read -r -a coordinates <<<"$resolution"
If you actually want the values in separate variables:
IFS=x read -r width height <<<"$resolution"
Upvotes: 3