Sample Header Ad - 728x90

Using curly braces to process colon-separated variables

6 votes
4 answers
826 views
If we do: VAR=100:200:300:400 We can do: echo ${VAR%%:*} 100 and echo ${VAR##*:} 400 Are there any equivalents I could use to get the values of 200 and 300? For instance, a way to get only what's between the second and third colon specifically in case there are more than just 3 colons?
Asked by Cestarian (2468 rep)
Apr 26, 2025, 03:54 AM
Last activity: Apr 26, 2025, 10:52 PM