ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
As already stated by onebuck, we don't give help for homework questions. The best way to learn is to try again and again until you find the answer by yourself. I can only suggest to read the official GNU awk user's guide, which is a very good text for learning the awk secrets. In chapter 5 you will find the answer to your question. In any case, show us your efforts and maybe we'll give some more specific directions.
Moved: This thread is more suitable in <Programming> and has been moved accordingly to help your thread/question get the exposure it deserves.
Note: We can help with homework, but you need to tell us more about the class, what books you are using, etc. In this case, have you used assignment statements to set the value of a variable?
That code looks like it's intended to be part of an AWK program. Is that correct? If so, you need something like rf=filename since that's the variable you read from "-."
Note, however, that your system call string (rpcmd = "sed 's/rf/uuu/' file > file1") is not correctly formatted. You need something like rpcmd = "sed \'s/" rf "/uuu/\' file > file1"
And, if you're using AWK, why bother using sed to do a simple substitution in a file that could be done easily in AWK itself?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.