Just as a BTW a trick I use fairly often is to make the thing I am working on contain spaces at key points and then do:technosaurus wrote:see "substring manipulation" in the advanced bash scripting guide.stu91 wrote:amigo wrote:All these loops and extraneous use of echo, sed and cut... Bash makes this very simple:Code: Select all
INDEX=${OUTSTR%%-*} FILENAME=${OUTSTR#*-}
Code: Select all
MyFunctionName $TheStringInQuestion
Inside the function I can then do all manner of stuff to the string. This is good when what you want to do is more complex than the example here because it makes it easier to document what is done.