Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-16-2009, 08:09 AM   #1
LQ Newbie
Registered: Aug 2009
Posts: 1

Rep: Reputation: 0
Taking the value from user


As shown in the program how can "rf" will take the value of "filename"
what should be the code ....?


# main logic is here

printf "Enter fime namr: "
getline filename < "-"

rpcmd = "sed 's/rf/uuu/' file > file1 "


# End action, if any, e.g. clean ups
Old 08-16-2009, 09:40 AM   #2
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,867
Blog Entries: 27

Rep: Reputation: 2162Reputation: 2162Reputation: 2162Reputation: 2162Reputation: 2162Reputation: 2162Reputation: 2162Reputation: 2162Reputation: 2162Reputation: 2162Reputation: 2162

Welcome to LQ!

I smell homework here?

Please read the LQ rules.
Old 08-16-2009, 10:06 AM   #3
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Hi and welcome to LinuxQuestions.

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.

Last edited by colucix; 08-16-2009 at 10:07 AM.
Old 08-16-2009, 10:36 AM   #4
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
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?
Old 08-16-2009, 12:46 PM   #5
Senior Member
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
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?


from, user, value

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Taking RHCE again rajaguru14 Linux - Newbie 2 11-24-2008 04:42 AM
[ruby with emacs] taking user input lilili Programming 2 01-18-2007 12:17 PM
Why I'm taking the plunge tanstaafl4y Member Intro 2 10-30-2006 12:33 PM
Taking my first steps. ellion Linux - Newbie 4 05-11-2006 01:13 AM
Taking Screenshots enik256 Linux - Newbie 5 03-02-2005 07:48 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:12 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration