til/bash-scripting/splitting-a-string-with-delimiter.md

9 lines
128 B
Markdown
Raw Normal View History

2021-07-03 16:18:51 +02:00
You can split a string with `cut`:
```bash
2021-07-03 16:18:51 +02:00
foo="hello-world-bye-world"
bar=$(echo $foo | cut -d"-" -f2)
echo $bar
# world
```