Bash_rematch
THe below is a java executalbe - If i execute it from the commnad line, without todays session
it strikes a error. Code:
casper ~ $ /data/execCommand ntf2201.1 /SPINMASTER/RELEASEALLEQUITIES Code:
#!/bin/bash I was looking into using the BASH_REMATCH - but it does not like the perl like regex \d{9}\w and when I use the postix, it does not seem to like that either. Anybody know of a good reference for the BASH_REMATCH? Can I parse/capture strings with BASH_REMATCH? Code:
#!/bin/bash |
Why not use
Code:
output="${output//[$'\t\n\v\f\r ']/}" The first line removes all whitespace from output. The second line removes everything up to and including the final colon from output. This should leave just the identifier in output. The test checks if output is at least two characters long, and contains digits 0-9 followed by letters A-Z or a-z (either may be omitted). In an UTF-8 locale, [A-Za-z] glob pattern may contain non-ASCII letters (although I think Bash has some bugs here currently). Explicitly setting the locale to POSIX will make sure that does not happen. In fact, you might wish to set the locale at the start of your script, and be done with it. It sure is ugly, though. After a second look, I think I'd personally use Code:
LC_ALL=C LANG=C Note that if there were more than one "ERROR...session:" in the first output, they would all be listed as separate parameters to the command. |
OK, I've been up for about 20 hours, so maybe I'm missing something, but AFAICT, you just want the final word from the output, right? If so, why not assign it to array and yank out the final word.
Code:
output=($(/data/execCmd $i /SPINMASTER/RELEASEALLEQUITIES)) Code:
output=$(/data/execCmd $i /SPINMASTER/RELEASEALLEQUITIES | awk '{print $NF}') |
When using exotic items, ie not just straight numbers and letters, i find it is best to store the regex in a variable, so something like the following should work:
Code:
#!/bin/bash |
All times are GMT -5. The time now is 02:36 PM. |