DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

I'm an enthusiastic software developer who tries to keep up with the all-time changing trends in software development. My interests go from trying new coding stuff, new design and architectural techniques, to studying how to encourage the adoption of new methodologies and tools in my organization. Martín has posted 8 posts at DZone. You can read more from them at their website. View Full User Profile

Bash Snippet: Split text and loop through the result

11.05.2013
| 2113 views |
  • submit to reddit
separator=':'
text_to_split=$PATH

paths=(`echo $PATH | tr $separator ' '`)

cant=${#paths[*]}
i=0
while [ $i -lt $cant ]; do
        echo ${paths[$i]}
	let i++
done

Splitting text and looping through the result