What's the most simple way to extract substring on Unix shell (with regex)?
Simple means:
- less feature
- less options
- less study
Update
I realized regex itself is conflicting with simplicity, and I chose the simplest one cut
as the chosen answer. I am sorry for vague question. I changed title to represent current state of this QA more precisely.
Best Answer
cut
might be useful:Shell Builtins are good for this too, here is a sample script:
That outputs:
And as per Gnudif above, there are always sed/awk/perl for when the going gets really tough.