Is there any implementation of scanf()(like in C) in awk(POSIX)?
I know that awk does not have back reference like in sed and perl.
What is the easiest way to simulate in awk?
Thanks
Nyan
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
sprintf() , printf() may be what you are looking for. awk does not support backreferences however gawk’s gensub(), or even gsub() can provide backreferences.
Backreferences are just storing the strings that are matched. So, making use of awk’s capability to differentiate fields and field delimiters, using its internal variables like OFS,FS,ORS etc are the way to go.. eg
Of course, this is just a simple example. But you get the idea.