Bash – Read from a certain point to a certain character

bashstring

Say I have a file like this:

foo bar foo bar foo bar foo bar something useful"foo bar foo bar"

Basically, I want to know how I can get the string something useful by itself, either saved to its own file or displayed as output alone.

There will always be the same number of characters (33) before something useful and there will always be " directly after it.

Best Answer

Try this:

cut -c 34- | cut -d '"' -f1

First cut removes the first 33 characters; second cut keeps only the part before the first ".

Related Question