I'm writing my first bash function, and I'm having a little bit of trouble getting used to the syntax. I have been told that it is very similar to Java, but I'm still not quite getting it.
The situation that I am dealing with is checking the values on input fields. There will be anywhere between two and five fields, so the code has to be able to adapt. The fields with either be a string, or a number. This is what I have so far...I am also using the match function, which I have never used before.
This function takes place within a file, which is used as a set of rules to be executed in an awk statement.
#is there a way to make a pointer for the field you are currently looking at?
function get(){
#do bash functions take on parameters?
#I don't know if it will be executed like get($i) or $i.get()?
if ( match( CURRENT FIELD? /�0' | [1-9][0-9]*/)
do something
if ( match( CURRENT FIELD? /[a-z]+/)
do something else
}
So, my question is, is there a way to have a pointer for the current field? I need to check each one, one by one, every time. I haven't been able to find this answer anywhere else, so I'm hoping someone can help me out.
Also, does the function in bash take parameters? Or would it be executed get( current field variable...???) or currentfieldvariable.get()?
I don't really need help with the "do something else" part of the code, because I know how to do it.