First I tried grepping the file using the matching only option and adjust from there;

                     # REGEX
function () {        # ((\w|ç|Ç|ñ|Ñ)+\s+\(\)\s+\{\n)
  blahblah           # (.*\n)+
}                    # (\})

…it worked except it was one giant match. Then I remembered about declare -f but it was sort of the same situation. I thought I could use some loop and redirect the output to files slapping a #!… on top, have a drink. Not quite; I overlooked that I'd need to break it apart first in order to loop the pieces and then > into files.

What I think I could do is work with the output of declare -F then use the array it outputs to declare -f /for entry in "${array[@]}". I think I might be over-complicating though, so I'd like to know how actual developers would do this.

Any advice you'd like to offer?
Thanks in adv. <3


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.