I have a string that contains a word and a number, like this:
\"6 ovenbread\"
How can I read the number (let\'s call it i) and fin
i
I think awk is easier, it has substr function, allows you to pick the n-th letter.
substr
awk '{print substr($2,$1,1)}'
with your data:
kent$ echo "6 ovenbread"|awk '{print substr($2,$1,1)}' r
No, you can't do that in sed, but it's easy enough in Awk.
sed
awk '{ print substr($2,$1,1) }' file