Bash substrings – just can’t figure it out…
gurus.knugum at gmail.com
Tue Jan 31 18:07:20 UTC 2012
I have read some about those built in substring tools built into Bash,
but still I don't understand them enough to use them.
Here's what I found at http://tldp.org/LDP/abs/html/string-manipulation.html:
Deletes shortest match of $substring from front of $string.
Deletes longest match of $substring from front of $string.”
I have an example here:
File="03. Rock Nuts.flac"
The result should be ”03. Rock .flac”, shouldn't it? Obviously not,
because the result is ”03. Rock Nuts.flac”, which is exactly the
So what am I missing?
What I originally really wanted to achieve was something quite
different: The opposite of the above; cutting out everything BUT
something. In this case I wanted to cut everything between ”. ” and
”.”, so that only ”Rock Nuts” is left in the example above. I know I
can do that very easily with awk, but how can I do it with the Bash
built in stuff?
More information about the ubuntu-users